Module: Liquidum::Options::ClassMethods

Defined in:
lib/liquidum/configuration.rb

Instance Method Summary collapse

Instance Method Details

#option(name, default: nil, proc: false) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/liquidum/configuration.rb', line 4

def option(name, default: nil, proc: false)
  attr_writer(name)
  schema[name] = {default: default, proc: proc}

  if schema[name][:proc]
    define_method(name) do |*params|
      value = instance_variable_get(:"@#{name}")
      instance_exec(*params, &value)
    end
  else
    define_method(name) do
      instance_variable_get(:"@#{name}")
    end
  end
end

#schemaObject



20
21
22
# File 'lib/liquidum/configuration.rb', line 20

def schema
  @schema ||= {}
end