Module: Temple::Mixins::ClassOptions

Included in:
Template
Defined in:
lib/temple/mixins/options.rb

Instance Method Summary collapse

Instance Method Details

#default_optionsObject



11
12
13
14
# File 'lib/temple/mixins/options.rb', line 11

def default_options
  warn 'default_options has been deprecated, use options'
  options
end

#define_deprecated_options(*opts) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/temple/mixins/options.rb', line 36

def define_deprecated_options(*opts)
  if opts.last.respond_to?(:to_hash)
    hash = opts.pop.to_hash
    options.add_deprecated_keys(hash.keys)
    options.update(hash)
  end
  options.add_deprecated_keys(opts)
end

#define_options(*opts) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/temple/mixins/options.rb', line 27

def define_options(*opts)
  if opts.last.respond_to?(:to_hash)
    hash = opts.pop.to_hash
    options.add_valid_keys(hash.keys)
    options.update(hash)
  end
  options.add_valid_keys(opts)
end

#disable_option_validator!Object



45
46
47
# File 'lib/temple/mixins/options.rb', line 45

def disable_option_validator!
  @option_validator_disabled = true
end

#optionsObject



20
21
22
23
24
25
# File 'lib/temple/mixins/options.rb', line 20

def options
  @options ||= OptionMap.new(superclass.respond_to?(:options) ?
                             superclass.options : nil) do |hash, key, what|
    warn "#{self}: Option #{key.inspect} is #{what}" unless @option_validator_disabled
  end
end

#set_default_options(opts) ⇒ Object



6
7
8
9
# File 'lib/temple/mixins/options.rb', line 6

def set_default_options(opts)
  warn 'set_default_options has been deprecated, use set_options'
  set_options(opts)
end

#set_options(opts) ⇒ Object



16
17
18
# File 'lib/temple/mixins/options.rb', line 16

def set_options(opts)
  options.update(opts)
end