Class: RPCMapper::Base

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

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 AssociationPreload

included

Methods included from Associations::External

included

Methods included from Associations::Contains

included

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.



29
30
31
32
# File 'lib/rpc_mapper/base.rb', line 29

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

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



20
21
22
# File 'lib/rpc_mapper/base.rb', line 20

def attributes
  @attributes
end

#new_recordObject Also known as: new_record?

Returns the value of attribute new_record.



20
21
22
# File 'lib/rpc_mapper/base.rb', line 20

def new_record
  @new_record
end

#read_optionsObject

Returns the value of attribute read_options.



20
21
22
# File 'lib/rpc_mapper/base.rb', line 20

def read_options
  @read_options
end

#write_optionsObject

Returns the value of attribute write_options.



20
21
22
# File 'lib/rpc_mapper/base.rb', line 20

def write_options
  @write_options
end

Class Method Details

.inherited(subclass) ⇒ Object



81
82
83
84
# File 'lib/rpc_mapper/base.rb', line 81

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

.new_from_data_store(hash) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/rpc_mapper/base.rb', line 61

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)


86
87
88
89
# File 'lib/rpc_mapper/base.rb', line 86

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

.unscopedObject



71
72
73
74
75
76
77
78
79
# File 'lib/rpc_mapper/base.rb', line 71

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



34
35
36
# File 'lib/rpc_mapper/base.rb', line 34

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