Class: Jiralicious::Field
- Defined in:
- lib/jiralicious/field.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(decoded_json, default = nil, &blk) ⇒ Field
constructor
A new instance of Field.
Methods inherited from Base
#all, #endpoint_name, endpoint_name, fetch, find, find_all, handler, #loaded?, #method_missing, #numeric?, parent_name, #parent_name, #properties_from_hash, #reload
Methods included from Parsers::FieldParser
Constructor Details
#initialize(decoded_json, default = nil, &blk) ⇒ Field
Returns a new instance of Field.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jiralicious/field.rb', line 6 def initialize(decoded_json, default = nil, &blk) @loaded = false if decoded_json.is_a? Hash decoded_json = properties_from_hash(decoded_json) super(decoded_json) parse!(decoded_json) self.each do |k, v| if v.is_a? Hash self[k] = self.class.new(v) elsif v.is_a? Array v.each_index do |i| if v[i].is_a? Hash v[i] = self.class.new(v[i]) end end self[k] = v end end @loaded = true else decoded_json.each do |list| if numeric? list['id'] id = :"id_#{list['id']}" else id = :"#{list['id']}" end self.class.property id out self.class.new(list) self.merge!({id => out}) end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jiralicious::Base