Class: RelationToJSON::BaseReflection

Inherits:
Object
  • Object
show all
Defined in:
lib/relation_to_json/base_reflection.rb

Direct Known Subclasses

BelongsToReflection, HasOneReflection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reflection, reflection_name, reflection_columns) ⇒ BaseReflection

Returns a new instance of BaseReflection.



10
11
12
13
14
# File 'lib/relation_to_json/base_reflection.rb', line 10

def initialize(reflection, reflection_name, reflection_columns)
  @reflection = reflection
  @name = reflection_name
  @required_columns = reflection_columns
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/relation_to_json/base_reflection.rb', line 7

def name
  @name
end

#reflectionObject (readonly)

Returns the value of attribute reflection.



7
8
9
# File 'lib/relation_to_json/base_reflection.rb', line 7

def reflection
  @reflection
end

#required_columnsObject

Returns the value of attribute required_columns.



8
9
10
# File 'lib/relation_to_json/base_reflection.rb', line 8

def required_columns
  @required_columns
end

Instance Method Details

#foreign_keyObject



22
23
24
# File 'lib/relation_to_json/base_reflection.rb', line 22

def foreign_key
  reflection.foreign_key.to_sym
end

#primary_keyObject



18
19
20
# File 'lib/relation_to_json/base_reflection.rb', line 18

def primary_key
  reflection.active_record.primary_key.to_sym
end