Class: Farscape::SafeRepresentorAgent
- Inherits:
-
Object
- Object
- Farscape::SafeRepresentorAgent
- Includes:
- BaseAgent
- Defined in:
- lib/farscape/representor.rb
Direct Known Subclasses
Constant Summary collapse
- EMPTY_BODIES =
TODO: Fix Representor to allow nil resources
{ hale: "{}" }
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#representor ⇒ Object
readonly
Returns the value of attribute representor.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #attributes ⇒ Object
- #embedded ⇒ Object
-
#initialize(requested_media_type, response, agent) ⇒ SafeRepresentorAgent
constructor
A new instance of SafeRepresentorAgent.
- #safe ⇒ Object
- #to_hash ⇒ Object
-
#transitions ⇒ Object
TODO: Handling list of transitions.
- #unsafe ⇒ Object
Methods included from BaseAgent
Constructor Details
#initialize(requested_media_type, response, agent) ⇒ SafeRepresentorAgent
Returns a new instance of SafeRepresentorAgent.
16 17 18 19 20 21 22 |
# File 'lib/farscape/representor.rb', line 16 def initialize(requested_media_type, response, agent) @agent = agent @response = response @requested_media_type = requested_media_type @representor = deserialize(requested_media_type, response.body) handle_extensions end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
10 11 12 |
# File 'lib/farscape/representor.rb', line 10 def agent @agent end |
#representor ⇒ Object (readonly)
Returns the value of attribute representor.
11 12 13 |
# File 'lib/farscape/representor.rb', line 11 def representor @representor end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
12 13 14 |
# File 'lib/farscape/representor.rb', line 12 def response @response end |
Instance Method Details
#attributes ⇒ Object
28 29 30 |
# File 'lib/farscape/representor.rb', line 28 def attributes representor.properties end |
#embedded ⇒ Object
37 38 39 |
# File 'lib/farscape/representor.rb', line 37 def Hash[representor..map{ |k, reps| [k, (reps, response)] }] end |
#safe ⇒ Object
45 46 47 |
# File 'lib/farscape/representor.rb', line 45 def safe reframe_representor(safe=true) end |
#to_hash ⇒ Object
41 42 43 |
# File 'lib/farscape/representor.rb', line 41 def to_hash @representor.to_hash end |
#transitions ⇒ Object
TODO: Handling list of transitions
33 34 35 |
# File 'lib/farscape/representor.rb', line 33 def transitions Hash[representor.transitions.map{ |trans| [trans.rel, Farscape::TransitionAgent.new(trans, agent)] }] end |
#unsafe ⇒ Object
49 50 51 |
# File 'lib/farscape/representor.rb', line 49 def unsafe reframe_representor(safe=false) end |