Sha256: 430ca378151600075d6bcd63020ec4cdc8d08f3c4a3fddaa5a3805da976c236c
Contents?: true
Size: 881 Bytes
Versions: 12
Compression:
Stored size: 881 Bytes
Contents
module Superstore::Associations::Builder class Association def self.build(model, name, options) new(model, name, options).build end attr_reader :model, :name, :options def initialize(model, name, options) @model, @name, @options = model, name, options end def build define_writer define_reader reflection = Superstore::Associations::Reflection.new(macro, name, model, options) ActiveRecord::Reflection.add_reflection model, name, reflection end def mixin model.generated_association_methods end def define_writer name = self.name mixin.redefine_method("#{name}=") do |records| association(name).writer(records) end end def define_reader name = self.name mixin.redefine_method(name) do association(name).reader end end end end
Version data entries
12 entries across 12 versions & 1 rubygems