Module: RubiGen::Options::ClassMethods

Defined in:
lib/rubigen/options.rb

Instance Method Summary collapse

Instance Method Details

#default_options(options = nil) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/rubigen/options.rb', line 29

def default_options(options = nil)
  if options
    write_inheritable_attribute(:default_options, options)
  else
    read_inheritable_attribute(:default_options) or write_inheritable_attribute(:default_options, {})
  end
end

#full_options(runtime_options = {}) ⇒ Object

Merge together our class options. In increasing precedence:

default_options   (class default options)
runtime_options   (provided as argument)
mandatory_options (class mandatory options)


41
42
43
# File 'lib/rubigen/options.rb', line 41

def full_options(runtime_options = {})
  default_options.merge(runtime_options).merge(mandatory_options)
end

#inherited_with_options(sub) ⇒ Object



16
17
18
19
# File 'lib/rubigen/options.rb', line 16

def inherited_with_options(sub)
  inherited_without_options(sub) if respond_to?(:inherited_without_options)
  sub.extend(RubiGen::Options::ClassMethods)
end

#mandatory_options(options = nil) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/rubigen/options.rb', line 21

def mandatory_options(options = nil)
  if options
    write_inheritable_attribute(:mandatory_options, options)
  else
    read_inheritable_attribute(:mandatory_options) or write_inheritable_attribute(:mandatory_options, {})
  end
end