Class: PricingPlans::Assignment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PricingPlans::Assignment
- Defined in:
- lib/pricing_plans/models/assignment.rb
Class Method Summary collapse
- .assign_plan_to(plan_owner, plan_key, source: "manual") ⇒ Object
- .remove_assignment_for(plan_owner) ⇒ Object
Instance Method Summary collapse
Class Method Details
.assign_plan_to(plan_owner, plan_key, source: "manual") ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pricing_plans/models/assignment.rb', line 23 def self.assign_plan_to(plan_owner, plan_key, source: "manual") assignment = find_or_initialize_by( plan_owner_type: plan_owner.class.name, plan_owner_id: plan_owner.id ) assignment.assign_attributes( plan_key: plan_key.to_s, source: source.to_s ) assignment.save! assignment end |
.remove_assignment_for(plan_owner) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/pricing_plans/models/assignment.rb', line 38 def self.remove_assignment_for(plan_owner) where( plan_owner_type: plan_owner.class.name, plan_owner_id: plan_owner.id ).destroy_all end |