Method: NsOptions::NamespaceData#ns_method_missing

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

#ns_method_missing(meth, *args, &block) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/ns-options/namespace_data.rb', line 132

def ns_method_missing(meth, *args, &block)
  dslm = DslMethod.new(meth, *args, &block)

  if is_namespace_reader?(dslm)
    get_namespace(dslm.name).define(&block)
  elsif is_option_reader?(dslm)
    get_option(dslm.name)
  elsif is_option_writer?(dslm)
    add_option(dslm.name) unless has_option?(dslm.name)
    set_option(dslm.name, dslm.data)
  else # namespace writer or unknown
    raise NoMethodError.new("undefined method `#{meth}' for #{@ns.inspect}")
  end
end