class Dart::DirectAssociation
Constants
- ATTRIBUTES
Public Class Methods
new(*args)
click to toggle source
Constructs a DirectAssociation
from the given attributes, which must correspond to ATTRIBUTES
defined above given either as separate arguments, a Hash, or an object that responds to methods corresponding to ATTRIBUTES
# File lib/dart/core/direct_association.rb, line 8 def initialize(*args) if args.length == 1 obj_or_hash = args.first obj = obj_or_hash.is_a?(Hash) ? OpenStruct.new(obj_or_hash) : obj_or_hash else obj = OpenStruct.new ATTRIBUTES.each_with_index {|a, i| obj.send("#{a}=", args[i])} end @child_table = obj.child_table.to_s.freeze or raise "No child table in #{obj_or_hash}" @foreign_key = obj.foreign_key.to_s.freeze or raise "No foreign_key in #{obj_or_hash}" @parent_table = obj.parent_table.to_s.freeze or raise "No parent_table in #{obj_or_hash}" @primary_key = obj.primary_key.to_s.freeze or raise "No primary_key in #{obj_or_hash}" end
Public Instance Methods
eql?(other)
click to toggle source
# File lib/dart/core/direct_association.rb, line 22 def eql?(other) ATTRIBUTES.all? { |f| send(f) == other.send(f) } end
Also aliased as: ==
hash()
click to toggle source
# File lib/dart/core/direct_association.rb, line 27 def hash ATTRIBUTES.map { |a| send(a) }.hash end
to_s()
click to toggle source
# File lib/dart/core/direct_association.rb, line 31 def to_s "#{self.class} #{ATTRIBUTES.map { |a| "#{a}: #{send(a)}" }.join(', ')}" end