Module: AttributeFu::Associations
- Defined in:
- lib/attribute_fu/associations.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
:nodoc:
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/attribute_fu/associations.rb', line 16 def method_missing(method_name, *args) #:nodoc: if method_name.to_s =~ /.+?\_attributes=/ association_name = method_name.to_s.gsub '_attributes=', '' association = managed_association_attributes.keys.detect { |element| element == association_name.to_sym } || managed_association_attributes.keys.detect { |element| element == association_name.pluralize.to_sym } unless association.nil? has_many_attributes association, args.first return end end super end |
Class Method Details
.included(base) ⇒ Object
:nodoc:
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/attribute_fu/associations.rb', line 4 def self.included(base) #:nodoc: base.class_eval do extend ClassMethods class << self; alias_method_chain :has_many, :association_option; end class_inheritable_accessor :managed_association_attributes write_inheritable_attribute :managed_association_attributes, {} after_update :save_managed_associations end end |