module Temple::Mixins::DefaultOptions

@api public

Public Instance Methods

default_options() click to toggle source
# File lib/temple/mixins/options.rb, line 9
def default_options
  @default_options ||= OptionHash.new(superclass.respond_to?(:default_options) ?
                                      superclass.default_options : nil) do |hash, key, deprecated|
    unless @option_validator_disabled
      if deprecated
        warn "Option #{key.inspect} is deprecated by #{self}"
      else
        # TODO: This will raise an exception in the future!
        # raise ArgumentError, "Option #{key.inspect} is not supported by #{self}"
        warn "Option #{key.inspect} is not supported by #{self}"
      end
    end
  end
end
define_deprecated_options(*opts) click to toggle source
# File lib/temple/mixins/options.rb, line 33
def define_deprecated_options(*opts)
  if opts.last.respond_to?(:to_hash)
    hash = opts.pop.to_hash
    default_options.add_deprecated_keys(hash.keys)
    default_options.update(hash)
  end
  default_options.add_deprecated_keys(opts)
end
define_options(*opts) click to toggle source
# File lib/temple/mixins/options.rb, line 24
def define_options(*opts)
  if opts.last.respond_to?(:to_hash)
    hash = opts.pop.to_hash
    default_options.add_valid_keys(hash.keys)
    default_options.update(hash)
  end
  default_options.add_valid_keys(opts)
end
disable_option_validator!() click to toggle source
# File lib/temple/mixins/options.rb, line 42
def disable_option_validator!
  @option_validator_disabled = true
end
set_default_options(opts) click to toggle source
# File lib/temple/mixins/options.rb, line 5
def set_default_options(opts)
  default_options.update(opts)
end