Class: RPCMapper::Base

Inherits:
Object
  • Object
show all
Includes:
Associations::Contains, Associations::External, ConfigOptions, Scopes, Serialization
Defined in:
lib/rpc_mapper/base.rb

Constant Summary collapse

@@adapter_pool =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Scopes

included

Methods included from Serialization

included

Methods included from Associations::External

included

Methods included from Associations::Contains

included

Methods included from ConfigOptions

included

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.



59
60
61
62
# File 'lib/rpc_mapper/base.rb', line 59

def initialize(attributes={})
  self.new_record = true
  set_attributes(attributes)
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



38
39
40
# File 'lib/rpc_mapper/base.rb', line 38

def attributes
  @attributes
end

#new_recordObject Also known as: new_record?

Returns the value of attribute new_record.



38
39
40
# File 'lib/rpc_mapper/base.rb', line 38

def new_record
  @new_record
end

Class Method Details

.inherited(subclass) ⇒ Object



111
112
113
114
# File 'lib/rpc_mapper/base.rb', line 111

def inherited(subclass)
  update_extension_map(self, subclass)
  super
end

.new_from_data_store(hash) ⇒ Object



91
92
93
94
95
96
97
98
99
# File 'lib/rpc_mapper/base.rb', line 91

def new_from_data_store(hash)
  if hash.nil?
    nil
  else
    record = self.new(hash)
    record.new_record = false
    record
  end
end

.respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


116
117
118
119
# File 'lib/rpc_mapper/base.rb', line 116

def respond_to?(method, include_private=false)
  super ||
  scoped.dynamic_finder_method(method)
end

.unscopedObject



101
102
103
104
105
106
107
108
109
# File 'lib/rpc_mapper/base.rb', line 101

def unscoped
  current_scopes = self.scoped_methods
  self.scoped_methods = []
  begin
    yield
  ensure
    self.scoped_methods = current_scopes
  end
end

Instance Method Details

#[](attribute) ⇒ Object



64
65
66
# File 'lib/rpc_mapper/base.rb', line 64

def [](attribute)
  @attributes[attribute.to_s]
end