Module: ActsAs::ClassMethods
- Defined in:
- lib/acts_as.rb
Instance Method Summary collapse
- #acts_as(association, type = :belongs_to, with: [], prefix: [], **options) ⇒ Object
- #acts_as_fields ⇒ Object
Instance Method Details
#acts_as(association, type = :belongs_to, with: [], prefix: [], **options) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/acts_as.rb', line 23 def acts_as(association, type = :belongs_to, with: [], prefix: [], **) type == :belongs_to ? belongs_to(association, **) : has_one(association, **) define_method(association) { |*args| super(*args) || send("build_#{association}", *args) } if (association_class = new.send(association).class).table_exists? whitelist_and_delegate_fields(association_class, association, prefix, with) override_method_missing end end |
#acts_as_fields ⇒ Object
33 34 35 |
# File 'lib/acts_as.rb', line 33 def acts_as_fields @acts_as_fields ||= {} end |