Class: ResoTransport::Resource
- Inherits:
-
Struct
- Object
- Struct
- ResoTransport::Resource
- Defined in:
- lib/reso_transport/resource.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#entity_set ⇒ Object
Returns the value of attribute entity_set.
Instance Method Summary collapse
- #entity_type ⇒ Object
- #expandable ⇒ Object
- #get(params) ⇒ Object
- #inspect ⇒ Object
- #md ⇒ Object
- #name ⇒ Object
- #parse(results) ⇒ Object
- #properties ⇒ Object
- #property(name) ⇒ Object
- #query ⇒ Object
- #schema ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client
2 3 4 |
# File 'lib/reso_transport/resource.rb', line 2 def client @client end |
#entity_set ⇒ Object
Returns the value of attribute entity_set
2 3 4 |
# File 'lib/reso_transport/resource.rb', line 2 def entity_set @entity_set end |
Instance Method Details
#entity_type ⇒ Object
24 25 26 |
# File 'lib/reso_transport/resource.rb', line 24 def entity_type @entity_type ||= schema.entity_types.detect {|et| et.name == entity_set.entity_type } end |
#expandable ⇒ Object
20 21 22 |
# File 'lib/reso_transport/resource.rb', line 20 def entity_type. end |
#get(params) ⇒ Object
40 41 42 43 44 |
# File 'lib/reso_transport/resource.rb', line 40 def get(params) client.connection.get(name, params) do |req| req.headers['Accept'] = 'application/json' end end |
#inspect ⇒ Object
50 51 52 |
# File 'lib/reso_transport/resource.rb', line 50 def inspect to_s end |
#md ⇒ Object
32 33 34 |
# File 'lib/reso_transport/resource.rb', line 32 def md client. end |
#name ⇒ Object
8 9 10 |
# File 'lib/reso_transport/resource.rb', line 8 def name entity_set.name end |
#parse(results) ⇒ Object
36 37 38 |
# File 'lib/reso_transport/resource.rb', line 36 def parse(results) results.map {|r| entity_type.parse(r) } end |
#properties ⇒ Object
16 17 18 |
# File 'lib/reso_transport/resource.rb', line 16 def properties entity_type.properties end |
#property(name) ⇒ Object
12 13 14 |
# File 'lib/reso_transport/resource.rb', line 12 def property(name) properties.detect {|p| p.name == name } end |
#query ⇒ Object
4 5 6 |
# File 'lib/reso_transport/resource.rb', line 4 def query Query.new(self) end |
#schema ⇒ Object
28 29 30 |
# File 'lib/reso_transport/resource.rb', line 28 def schema @schema ||= md.schemas.detect {|s| s.namespace == entity_set.schema } end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/reso_transport/resource.rb', line 46 def to_s %(#<ResoTransport::Resource entity_set="#{name}", schema="#{schema&.namespace}">) end |