Module: Cookbook::Mixins::ActsAsUsedIn::ClassMethods
- Defined in:
- lib/cookbook/mixins/acts_as_used_in.rb
Overview
Extended by acts_as_used_in mixin
Instance Attribute Summary collapse
-
#label_method ⇒ Object
Returns the value of attribute label_method.
-
#use_of ⇒ Object
Returns the value of attribute use_of.
Instance Method Summary collapse
Instance Attribute Details
#label_method ⇒ Object
Returns the value of attribute label_method.
41 42 43 |
# File 'lib/cookbook/mixins/acts_as_used_in.rb', line 41 def label_method @label_method end |
#use_of ⇒ Object
Returns the value of attribute use_of.
41 42 43 |
# File 'lib/cookbook/mixins/acts_as_used_in.rb', line 41 def use_of @use_of end |
Instance Method Details
#associate_uses_of ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cookbook/mixins/acts_as_used_in.rb', line 43 def associate_uses_of self.use_of.each do |table_sym| model = table_sym.to_s.classify.constantize name = model.model_name.to_s has_many "#{model.model_name.param_key}_uses".to_sym, lambda { where(use_in_type: name) }, as: :use_of, class_name: 'Cookbook::Use' has_many table_sym, through: :uses, source: :use_in, source_type: name end end |