Class: Polymorpheus::InterfaceBuilder::Association

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Inflector
Defined in:
lib/polymorpheus/interface_builder/association.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Association

Returns a new instance of Association.



10
11
12
13
# File 'lib/polymorpheus/interface_builder/association.rb', line 10

def initialize(name)
  @name = name.to_s.downcase
  @key = "#{@name}_id"
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/polymorpheus/interface_builder/association.rb', line 7

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/polymorpheus/interface_builder/association.rb', line 7

def name
  @name
end

Instance Method Details

#association_classObject

The association class may not be loaded at the time this object is initialized, so we can’t set it via an accessor in the initializer.



17
18
19
# File 'lib/polymorpheus/interface_builder/association.rb', line 17

def association_class
  @association_class ||= name.classify.constantize
end