Class: Loggly::Model
- Inherits:
-
Object
- Object
- Loggly::Model
- Extended by:
- ClassMethods
- Includes:
- Logging
- Defined in:
- lib/loggly/model.rb
Direct Known Subclasses
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- METADATA_KEYS =
{}
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Model
constructor
A new instance of Model.
- #to_hash ⇒ Object
- #to_json(pretty = false) ⇒ Object
- #to_log(options = {}) ⇒ Object
Methods included from ClassMethods
Methods included from Logging
#init_logger, #logger, #logger=
Constructor Details
#initialize(attributes = {}) ⇒ Model
Returns a new instance of Model.
9 10 11 12 |
# File 'lib/loggly/model.rb', line 9 def initialize(attributes = {}) @attributes = OpenStruct.new(attributes) @response = nil end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/loggly/model.rb', line 7 def attributes @attributes end |
#response ⇒ Object
Returns the value of attribute response.
7 8 9 |
# File 'lib/loggly/model.rb', line 7 def response @response end |
Instance Method Details
#to_hash ⇒ Object
14 15 16 |
# File 'lib/loggly/model.rb', line 14 def to_hash @attributes.marshal_dump end |
#to_json(pretty = false) ⇒ Object
18 19 20 |
# File 'lib/loggly/model.rb', line 18 def to_json(pretty = false) MultiJson.dump(self.to_hash, :pretty => pretty) end |
#to_log(options = {}) ⇒ Object
22 23 24 |
# File 'lib/loggly/model.rb', line 22 def to_log( = {}) self.to_json(true) end |