Module: AMON::JSONHelper::ClassMethods
- Defined in:
- lib/amon/json_helper.rb
Instance Method Summary collapse
Instance Method Details
#field(name, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/amon/json_helper.rb', line 16 def field(name, = {}) class_eval do define_method(name) do original_value = json[([:name] || name).to_s] if original_value.nil? [:default] else case [:as].to_s when 'Time' Time.parse(original_value) else original_value end end end end end |