Class: Boxxspring::Synchronization::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/boxxspring/synchronization/configuration.rb

Class Method Summary collapse

Class Method Details

.field(field_name, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/boxxspring/synchronization/configuration.rb', line 9

def self.field( field_name, options = {} )

  class_eval(
    "def #{field_name}( *arguments ); " +
       "@#{field_name} = arguments.first unless arguments.empty?; " +
       "@#{field_name} || " +
         ( options[ :default ].blank? ?
            "nil" :
            ( options[ :default ].is_a?( String ) ? 
                "'#{options[ :default ]}'" : 
                  "#{options[ :default ]}" ) ) + ";" +
    "end",
    __FILE__, 
    __LINE__
  )

end