Module: MarkMapper::Plugins::Rails

Extended by:
ActiveSupport::Concern
Included in:
Document, EmbeddedDocument
Defined in:
lib/mark_mapper/plugins/rails.rb,
lib/mark_mapper/plugins/rails/active_record_association_adapter.rb

Defined Under Namespace

Modules: ClassMethods Classes: ActiveRecordAssociationAdapter

Instance Method Summary collapse

Instance Method Details

#new_record?Boolean


20
21
22
# File 'lib/mark_mapper/plugins/rails.rb', line 20

def new_record?
  new?
end

#read_attribute(name) ⇒ Object


24
25
26
# File 'lib/mark_mapper/plugins/rails.rb', line 24

def read_attribute(name)
  self[name]
end

#read_attribute_before_type_cast(name) ⇒ Object


28
29
30
31
32
33
34
35
# File 'lib/mark_mapper/plugins/rails.rb', line 28

def read_attribute_before_type_cast(name)
  @__mm_pre_cast ||= {}
  name = unalias_key name
  if !@__mm_pre_cast.key?(name)
    @__mm_pre_cast[name] = read_attribute(name)
  end
  @__mm_pre_cast[name]
end

#to_keyObject


16
17
18
# File 'lib/mark_mapper/plugins/rails.rb', line 16

def to_key
  [id] if persisted?
end

#to_modelObject


12
13
14
# File 'lib/mark_mapper/plugins/rails.rb', line 12

def to_model
  self
end

#to_paramObject


8
9
10
# File 'lib/mark_mapper/plugins/rails.rb', line 8

def to_param
  id.to_s if persisted?
end

#write_attribute(name, value) ⇒ Object


37
38
39
40
# File 'lib/mark_mapper/plugins/rails.rb', line 37

def write_attribute(name, value)
  self[name] = value
  self[name]
end

#write_key(name, value) ⇒ Object


42
43
44
45
46
47
# File 'lib/mark_mapper/plugins/rails.rb', line 42

def write_key(name, value)
  name = unalias_key name
  @__mm_pre_cast ||= {}
  @__mm_pre_cast[name.to_s] = value
  super
end