Module: Yogo::Data::DefaultMethods::ClassMethods
- Defined in:
- lib/yogo/data/default_methods.rb
Instance Method Summary collapse
- #labeled_properties ⇒ Object
- #parse_json(body) ⇒ Object
- #schema ⇒ Object
- #unlabeled_properties ⇒ Object
Instance Method Details
#labeled_properties ⇒ Object
29 30 31 |
# File 'lib/yogo/data/default_methods.rb', line 29 def labeled_properties properties.select{|p| !p.['label'].nil? } end |
#parse_json(body) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/yogo/data/default_methods.rb', line 15 def parse_json(body) json = JSON.parse(body) props = labeled_properties ret = {} # I don't think we care about other items passed back. json['data'].each_pair do |key,value| property = props.select{|p| p.['label'] == key || p.name.to_s == key} return nil unless property.length == 1 # raise Exception, "There shouldn't be more the one property with the same label" ret[property.first.name] = value end return ret end |
#schema ⇒ Object
11 12 13 |
# File 'lib/yogo/data/default_methods.rb', line 11 def schema class_variable_get(:@@schema) end |
#unlabeled_properties ⇒ Object
33 34 35 |
# File 'lib/yogo/data/default_methods.rb', line 33 def unlabeled_properties properties.select{|p| p.['label'].nil? } end |