Module: Graft::Json::Model::ClassMethods
- Defined in:
- lib/graft/lib/graft/json/model.rb
Instance Method Summary collapse
Instance Method Details
#attribute(name, options = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/graft/lib/graft/json/model.rb', line 7 def attribute(name, = {}) source = [:from] self.attributes << Graft::Json::Attribute.new(name, source) class_eval "attr_accessor :#{name}" end |
#data_from(json_or_hash) ⇒ Object
14 15 16 |
# File 'lib/graft/lib/graft/json/model.rb', line 14 def data_from(json_or_hash) json_or_hash.is_a?(String) ? JSON.parse(json_or_hash) : json_or_hash end |