Class: ModelExplorer::Associations::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/model_explorer/associations/base.rb

Direct Known Subclasses

Many, Singular

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, reflection, association) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
# File 'lib/model_explorer/associations/base.rb', line 10

def initialize(record, reflection, association)
  @record = record
  @reflection = reflection
  @association = association
end

Instance Attribute Details

#associationObject (readonly)

Returns the value of attribute association.



8
9
10
# File 'lib/model_explorer/associations/base.rb', line 8

def association
  @association
end

#recordObject (readonly)

Returns the value of attribute record.



8
9
10
# File 'lib/model_explorer/associations/base.rb', line 8

def record
  @record
end

#reflectionObject (readonly)

Returns the value of attribute reflection.



8
9
10
# File 'lib/model_explorer/associations/base.rb', line 8

def reflection
  @reflection
end

Instance Method Details

#exportObject

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/model_explorer/associations/base.rb', line 16

def export
  raise NotImplementedError
end

#recordsObject



20
21
22
23
24
25
26
# File 'lib/model_explorer/associations/base.rb', line 20

def records
  @_records ||=
    klass
    .connection
    .exec_query(query.to_sql)
    .map { |record_attributes| build_record(record_attributes) }
end