Class: SmartEnum::Associations::ThroughAssociation

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_enum/associations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(association_name, through_association, source: nil) ⇒ ThroughAssociation

Returns a new instance of ThroughAssociation.



145
146
147
148
149
# File 'lib/smart_enum/associations.rb', line 145

def initialize(association_name, through_association, source: nil)
  @association_name = association_name
  @through_association = through_association.to_sym
  @source_option = source
end

Instance Attribute Details

#association_nameObject (readonly)

Returns the value of attribute association_name.



143
144
145
# File 'lib/smart_enum/associations.rb', line 143

def association_name
  @association_name
end

#source_optionObject (readonly)

Returns the value of attribute source_option.



143
144
145
# File 'lib/smart_enum/associations.rb', line 143

def source_option
  @source_option
end

#through_associationObject (readonly)

Returns the value of attribute through_association.



143
144
145
# File 'lib/smart_enum/associations.rb', line 143

def through_association
  @through_association
end

Instance Method Details

#association_methodObject



151
152
153
# File 'lib/smart_enum/associations.rb', line 151

def association_method
  @association_method ||= (source_option || association_name)
end