Class: Zermelo::Associations::AssociationData

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ AssociationData

Returns a new instance of AssociationData.



8
9
10
11
12
13
14
# File 'lib/zermelo/associations/association_data.rb', line 8

def initialize(opts = {})
  [:name, :type_klass, :data_type, :inverse, :sort_key, :sort_order,
   :callbacks, :data_klass_name, :related_klass_names].each do |a|

    send("#{a}=".to_sym, opts[a])
  end
end

Instance Attribute Details

#callbacksObject

Returns the value of attribute callbacks.



5
6
7
# File 'lib/zermelo/associations/association_data.rb', line 5

def callbacks
  @callbacks
end

#data_klass_name=(value) ⇒ Object (writeonly)

Sets the attribute data_klass_name

Parameters:

  • value

    the value to set the attribute data_klass_name to.



4
5
6
# File 'lib/zermelo/associations/association_data.rb', line 4

def data_klass_name=(value)
  @data_klass_name = value
end

#data_typeObject

Returns the value of attribute data_type.



5
6
7
# File 'lib/zermelo/associations/association_data.rb', line 5

def data_type
  @data_type
end

#inverseObject

Returns the value of attribute inverse.



5
6
7
# File 'lib/zermelo/associations/association_data.rb', line 5

def inverse
  @inverse
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/zermelo/associations/association_data.rb', line 5

def name
  @name
end

Sets the attribute related_klass_names

Parameters:

  • value

    the value to set the attribute related_klass_names to.



4
5
6
# File 'lib/zermelo/associations/association_data.rb', line 4

def related_klass_names=(value)
  @related_klass_names = value
end

#sort_keyObject

Returns the value of attribute sort_key.



5
6
7
# File 'lib/zermelo/associations/association_data.rb', line 5

def sort_key
  @sort_key
end

#sort_orderObject

Returns the value of attribute sort_order.



5
6
7
# File 'lib/zermelo/associations/association_data.rb', line 5

def sort_order
  @sort_order
end

#type_klassObject

Returns the value of attribute type_klass.



5
6
7
# File 'lib/zermelo/associations/association_data.rb', line 5

def type_klass
  @type_klass
end

Instance Method Details

#data_klassObject



16
17
18
# File 'lib/zermelo/associations/association_data.rb', line 16

def data_klass
  @data_klass ||= @data_klass_name.constantize
end


20
21
22
# File 'lib/zermelo/associations/association_data.rb', line 20

def related_klasses
  @related_klasses ||= (@related_klass_names || []).map(&:constantize)
end