Module: Leadlight::Representation
- Defined in:
- lib/leadlight/representation.rb
Instance Attribute Summary collapse
-
#__location__ ⇒ Object
Returns the value of attribute __location__.
-
#__response__ ⇒ Object
Returns the value of attribute __response__.
-
#__service__ ⇒ Object
Returns the value of attribute __service__.
Instance Method Summary collapse
- #apply_all_tints ⇒ Object
- #exception(message = exception_message) ⇒ Object
- #exception_message ⇒ Object
- #http_status_message ⇒ Object
- #initialize_representation(service, location, response) ⇒ Object
Instance Attribute Details
#__location__ ⇒ Object
Returns the value of attribute __location__.
8 9 10 |
# File 'lib/leadlight/representation.rb', line 8 def __location__ @__location__ end |
#__response__ ⇒ Object
Returns the value of attribute __response__.
9 10 11 |
# File 'lib/leadlight/representation.rb', line 9 def __response__ @__response__ end |
#__service__ ⇒ Object
Returns the value of attribute __service__.
7 8 9 |
# File 'lib/leadlight/representation.rb', line 7 def __service__ @__service__ end |
Instance Method Details
#apply_all_tints ⇒ Object
18 19 20 21 22 |
# File 'lib/leadlight/representation.rb', line 18 def apply_all_tints __service__.tints.inject(self, &:extend) __apply_tint__ self end |
#exception(message = exception_message) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/leadlight/representation.rb', line 24 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(__response__, ) end |
#exception_message ⇒ Object
33 34 35 |
# File 'lib/leadlight/representation.rb', line 33 def end |
#http_status_message ⇒ Object
37 38 39 40 41 |
# File 'lib/leadlight/representation.rb', line 37 def __response__.env.fetch(:response_headers).fetch('status'){ status.to_s } end |
#initialize_representation(service, location, response) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/leadlight/representation.rb', line 11 def initialize_representation(service, location, response) self.__service__ = service self.__location__ = location self.__response__ = response self end |