Class: LegacyEnum::MethodDefinitionDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/legacy_enum/method_definition_dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/legacy_enum/method_definition_dsl.rb', line 5

def method_missing(symbol, *args)
  @enum_def ||= []
  @enum_def.singleton_class.send :include, ConfigurationSearch
  
  options = args.extract_options!
  
  options.merge! name: symbol
  options.merge! value: args[0] unless args.empty?
  options.merge! label: symbol.to_s.titleize unless options.keys.include?(:label) 
  
  @enum_def << options  
end

Instance Attribute Details

#enum_defObject

Returns the value of attribute enum_def.



3
4
5
# File 'lib/legacy_enum/method_definition_dsl.rb', line 3

def enum_def
  @enum_def
end