Module: Leadlight::Representation
- Extended by:
- Forwardable
- Defined in:
- lib/leadlight/representation.rb
Instance Attribute Summary collapse
-
#__location__ ⇒ Object
Returns the value of attribute __location__.
-
#__request__ ⇒ Object
Returns the value of attribute __request__.
-
#__response__ ⇒ Object
Returns the value of attribute __response__.
-
#__service__ ⇒ Object
Returns the value of attribute __service__.
Instance Method Summary collapse
- #__captures__ ⇒ Object
- #__link__ ⇒ Object
- #__request_params__ ⇒ Object
- #apply_all_tints ⇒ Object
- #exception ⇒ Object
- #exception_message ⇒ Object
- #http_status_message ⇒ Object
-
#initialize_representation(service, location, response, request) ⇒ Object
fattr(:__captures__) { {} }.
Instance Attribute Details
#__location__ ⇒ Object
Returns the value of attribute __location__.
12 13 14 |
# File 'lib/leadlight/representation.rb', line 12 def __location__ @__location__ end |
#__request__ ⇒ Object
Returns the value of attribute __request__.
14 15 16 |
# File 'lib/leadlight/representation.rb', line 14 def __request__ @__request__ end |
#__response__ ⇒ Object
Returns the value of attribute __response__.
13 14 15 |
# File 'lib/leadlight/representation.rb', line 13 def __response__ @__response__ end |
#__service__ ⇒ Object
Returns the value of attribute __service__.
11 12 13 |
# File 'lib/leadlight/representation.rb', line 11 def __service__ @__service__ end |
Instance Method Details
#__captures__ ⇒ Object
59 60 61 |
# File 'lib/leadlight/representation.rb', line 59 def __captures__ @__captures__ ||= {} end |
#__link__ ⇒ Object
51 52 53 |
# File 'lib/leadlight/representation.rb', line 51 def __link__ __request__.link end |
#__request_params__ ⇒ Object
55 56 57 |
# File 'lib/leadlight/representation.rb', line 55 def __request_params__ __request__.params end |
#apply_all_tints ⇒ Object
26 27 28 29 30 |
# File 'lib/leadlight/representation.rb', line 26 def apply_all_tints __service__.tints.inject(self, &:extend) __apply_tint__ self end |
#exception ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/leadlight/representation.rb', line 32 def exception return super if defined?(super) case __response__.status.to_i when 404 then ResourceNotFound when (400..499) then ClientError when (500..599) then ServerError end.new(__request__, ) end |
#exception_message ⇒ Object
41 42 43 |
# File 'lib/leadlight/representation.rb', line 41 def end |
#http_status_message ⇒ Object
45 46 47 48 49 |
# File 'lib/leadlight/representation.rb', line 45 def __response__.env.fetch(:response_headers).fetch('status'){ status.to_s } end |
#initialize_representation(service, location, response, request) ⇒ Object
fattr(:__captures__) { {} }
18 19 20 21 22 23 24 |
# File 'lib/leadlight/representation.rb', line 18 def initialize_representation(service, location, response, request) self.__service__ = service self.__location__ = location self.__response__ = response self.__request__ = request self end |