Module: DataBroker::Mapper::ClassMethods

Defined in:
lib/data_broker/mapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



20
21
22
# File 'lib/data_broker/mapper.rb', line 20

def children
  @children
end

#mappingObject

Returns the value of attribute mapping.



20
21
22
# File 'lib/data_broker/mapper.rb', line 20

def mapping
  @mapping
end

#modelObject

Returns the value of attribute model.



20
21
22
# File 'lib/data_broker/mapper.rb', line 20

def model
  @model
end

#parentsObject

Returns the value of attribute parents.



20
21
22
# File 'lib/data_broker/mapper.rb', line 20

def parents
  @parents
end

#recordObject

Returns the value of attribute record.



20
21
22
# File 'lib/data_broker/mapper.rb', line 20

def record
  @record
end

Instance Method Details

#all(eager_load: false) ⇒ Object



30
31
32
# File 'lib/data_broker/mapper.rb', line 30

def all(eager_load: false)
  construct_instance.all(:eager_load => eager_load)
end

#construct_instanceObject



50
51
52
53
54
55
# File 'lib/data_broker/mapper.rb', line 50

def construct_instance
  self.new(
    :mapping => mapping, :parents => parents, :children => children,
    :record => @record, :model => @model
  )
end

#destroy(model, eager_load: false) ⇒ Object



46
47
48
# File 'lib/data_broker/mapper.rb', line 46

def destroy(model, eager_load: false)
  construct_instance.destroy(model, :eager_load => eager_load)
end

#find(id, eager_load: true) ⇒ Object



34
35
36
# File 'lib/data_broker/mapper.rb', line 34

def find(id, eager_load: true)
  construct_instance.find(id, :eager_load => eager_load)
end

#save(model, eager_load: true) ⇒ Object



42
43
44
# File 'lib/data_broker/mapper.rb', line 42

def save(model, eager_load: true)
  construct_instance.save(model, :eager_load => eager_load)
end

#where(eager_load: true, **conds) ⇒ Object



38
39
40
# File 'lib/data_broker/mapper.rb', line 38

def where(eager_load: true, **conds)
  construct_instance.where(:eager_load => true, **conds)
end