Module: Itemable::ActsAsItemable::HasOneItem::ClassMethods
- Defined in:
- lib/itemable/acts_as_itemable.rb
Instance Method Summary collapse
Instance Method Details
#has_one_item(association_name, options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/itemable/acts_as_itemable.rb', line 58 def has_one_item(association_name, ={}) = { through: :item_child, source: :child, source_type: association_name.to_s.classify }.merge(.symbolize_keys) if [:dependent] == :destroy before_destroy prepend: true do rec = send(association_name) rec.destroy if rec end end has_one association_name, end |