Class: Bamboo::Client::Http::Json::Doc
- Inherits:
-
Object
- Object
- Bamboo::Client::Http::Json::Doc
- Defined in:
- lib/bamboo-client/http/json.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #auto_expand(klass, client) ⇒ Object
- #doc_for(key) ⇒ Object
-
#initialize(data) ⇒ Doc
constructor
A new instance of Doc.
Constructor Details
#initialize(data) ⇒ Doc
Returns a new instance of Doc.
14 15 16 17 |
# File 'lib/bamboo-client/http/json.rb', line 14 def initialize(data) @data = data pp @data if $DEBUG end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/bamboo-client/http/json.rb', line 8 def data @data end |
Class Method Details
.from(str) ⇒ Object
10 11 12 |
# File 'lib/bamboo-client/http/json.rb', line 10 def self.from(str) new JSON.parse(str) end |
Instance Method Details
#auto_expand(klass, client) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bamboo-client/http/json.rb', line 23 def (klass, client) = @data.fetch('expand') obj = @data[] case obj when Hash if obj.has_key?('expand') Doc.new(obj).(klass, client) else klass.new(obj, client) end when Array obj.map { |e| klass.new(e, client) } else raise TypeError, "don't know how to auto-expand #{obj.inspect}" end end |