module RiakRecord::Associations
Public Class Methods
included(base)
click to toggle source
# File lib/riak_record/associations.rb, line 74 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
link_definitions()
click to toggle source
# File lib/riak_record/associations.rb, line 18 def link_definitions self.class.link_definitions end
update_links()
click to toggle source
# File lib/riak_record/associations.rb, line 4 def update_links link_definitions.each_pair do |tag, definition| tag = tag.to_s bucket_name = Object.const_get(definition[:class_name].to_s).bucket_name.to_s key = self.send(definition[:foreign_key].to_sym).first # remove links with tag name self.links.delete_if{|l| l.tag.to_s == tag } # add link if key is set self.links << Riak::Link.new(bucket_name.to_s, key.to_s, tag.to_s) unless key.nil? end end