Module: Retter::Configurable

Included in:
Binder, Entries, Markdown, Page, Site
Defined in:
lib/retter/configurable.rb

Instance Method Summary collapse

Instance Method Details

#configurable(*names) ⇒ Object



5
6
7
8
9
10
# File 'lib/retter/configurable.rb', line 5

def configurable(*names)
  names.each do |name|
    define_configurable_method name
    define_instance_shortcut_method name
  end
end

#define_configurable_method(name) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/retter/configurable.rb', line 12

def define_configurable_method(name)
  instance_eval <<-EOM
    def #{name}(val = nil)
      val ? @#{name} = val : @#{name}
    end
  EOM
end

#define_instance_shortcut_method(name) ⇒ Object



20
21
22
23
24
# File 'lib/retter/configurable.rb', line 20

def define_instance_shortcut_method(name)
  define_method name do
    self.class.send(name)
  end
end