Module: NsOptions::HasOptions::DSL

Defined in:
lib/ns-options/has_options.rb

Instance Method Summary collapse

Instance Method Details

#options(name, key = nil, &block) ⇒ Object Also known as: opts

The options method takes three args:

  • ‘name` : what to name the defined methods for accessing the namespace

  • ‘key` : (optional) what to key the created namespace objects with

    - defaults to `name`
    - useful if persisting namespaces into some key-value store
    
  • ‘block`: (optional) a predefined set of nested options and namespaces



42
43
44
45
46
# File 'lib/ns-options/has_options.rb', line 42

def options(name, key = nil, &block)
  NsOptions::Helper.advisor.is_this_namespace_ok?(name, caller)
  NsOptions::Helper.define_root_namespace_methods(self, name, key)
  self.send(name, &block)
end