Class: Loggly::Model

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Includes:
Logging
Defined in:
lib/loggly/model.rb

Direct Known Subclasses

RemoteModel

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

METADATA_KEYS =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

from_hash, from_json

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

#attributesObject

Returns the value of attribute attributes.



7
8
9
# File 'lib/loggly/model.rb', line 7

def attributes
  @attributes
end

#responseObject

Returns the value of attribute response.



7
8
9
# File 'lib/loggly/model.rb', line 7

def response
  @response
end

Instance Method Details

#to_hashObject



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(options = {})
  self.to_json(true)
end