Permalink
Browse files

pass the mixin in to the code generation methods

  • Loading branch information...
1 parent bc06ee3 commit c856d895bd054d0c474f1a3876257400db529590 @tenderlove tenderlove committed Aug 1, 2013
@@ -54,7 +54,7 @@ def mixin
end
def build
- define_accessors
+ define_accessors(mixin)
configure_dependency if options[:dependent]
reflection = ActiveRecord::Reflection.create(macro, name, scope, options, model)
Association.extensions.each do |extension|
@@ -82,20 +82,20 @@ def validate_options
#
# Post.first.comments and Post.first.comments= methods are defined by this method...
- def define_accessors
- define_readers
- define_writers
+ def define_accessors(mixin)
+ define_readers(mixin)
+ define_writers(mixin)
end
- def define_readers
+ def define_readers(mixin)
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
def #{name}(*args)
association(:#{name}).reader(*args)
end
CODE
end
- def define_writers
+ def define_writers(mixin)
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
def #{name}=(value)
association(:#{name}).writer(value)
@@ -61,7 +61,7 @@ def define_callback(callback_name)
# Defines the setter and getter methods for the collection_singular_ids.
- def define_readers
+ def define_readers(mixin)
super
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
@@ -71,7 +71,7 @@ def #{name.to_s.singularize}_ids
CODE
end
- def define_writers
+ def define_writers(mixin)
super
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
@@ -10,14 +10,14 @@ def constructable?
true
end
- def define_accessors
+ def define_accessors(mixin)
super
- define_constructors if constructable?
+ define_constructors(mixin) if constructable?
end
# Defines the (build|create)_association methods for belongs_to or has_one association
- def define_constructors
+ def define_constructors(mixin)
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
def build_#{name}(*args, &block)
association(:#{name}).build(*args, &block)

0 comments on commit c856d89

Please sign in to comment.