Class: RouteNGNClient::Model

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

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Attributes included from ClassMethods

#children, #only_children, #parents

Instance Method Summary collapse

Methods included from ClassMethods

belongs_to, from_hash, from_json, has_many, has_one

Methods included from Logging

#init_logger, #logger

Constructor Details

#initialize(attributes = {}) ⇒ Model

Returns a new instance of Model.



7
8
9
10
11
12
13
# File 'lib/routengn_client/model.rb', line 7

def initialize(attributes = {})
  @attributes = OpenStruct.new(attributes)
  @request_account_id = nil
  self.create_parent_accessors
  self.create_child_accessors
  self.create_only_child_accessors
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



5
6
7
# File 'lib/routengn_client/model.rb', line 5

def attributes
  @attributes
end

#request_account_idObject

Returns the value of attribute request_account_id.



5
6
7
# File 'lib/routengn_client/model.rb', line 5

def 
  @request_account_id
end

Instance Method Details

#to_hashObject



15
16
17
# File 'lib/routengn_client/model.rb', line 15

def to_hash
  @attributes.marshal_dump
end

#to_json(pretty = false) ⇒ Object



19
20
21
# File 'lib/routengn_client/model.rb', line 19

def to_json(pretty = false)
  MultiJson.dump(self.to_hash, :pretty => pretty)      
end

#to_log(options = {}) ⇒ Object



23
24
25
# File 'lib/routengn_client/model.rb', line 23

def to_log(options = {})
  self.to_json(true)
end