Sha256: 1839e39bf07d630ea7c8ae896155e42ad6f23a6528fb08b49121f043b958050c
Contents?: true
Size: 816 Bytes
Versions: 7
Compression:
Stored size: 816 Bytes
Contents
module Associations def has_many(resource, options={}) class_name = options[:class_name] || "Sfn::#{resource.to_s.classify}" class_eval do define_method resource do instance_variable_get("@#{resource}") || instance_variable_set("@#{resource}", Sfn::ResourceCollection.new(class_name.constantize, self.satisfaction, options[:url])) end end end def belongs_to(resource, options={}) class_name = options[:class_name] || "Sfn::#{resource.to_s.classify}" parent_id = options[:parent_attribute] || "#{resource}_id" class_eval do define_method resource do instance_variable_get("@#{resource}") || instance_variable_set("@#{resource}", class_name.constantize.new(parent_id, self.satisfaction)) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems