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
- .clear_pricing_plan_override_for!(plan_owner) ⇒ Object
- .create_or_update_pricing_plan_override_for!(plan_owner, plan_key, source:) ⇒ Object
- .remove_assignment_for(plan_owner) ⇒ Object
Instance Method Summary collapse
Class Method Details
.assign_plan_to(plan_owner, plan_key, source: "manual") ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/pricing_plans/models/assignment.rb', line 45 def self.assign_plan_to(plan_owner, plan_key, source: "manual") LegacyPlanAssignmentApi.create_or_update_override!( plan_owner, plan_key, source: source, called_method_name: "PricingPlans::Assignment.assign_plan_to" ) end |
.clear_pricing_plan_override_for!(plan_owner) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/pricing_plans/models/assignment.rb', line 38 def self.clear_pricing_plan_override_for!(plan_owner) where( plan_owner_type: plan_owner.class.name, plan_owner_id: plan_owner.id ).destroy_all end |
.create_or_update_pricing_plan_override_for!(plan_owner, plan_key, source:) ⇒ 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.create_or_update_pricing_plan_override_for!(plan_owner, plan_key, source:) 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
54 55 56 57 58 59 |
# File 'lib/pricing_plans/models/assignment.rb', line 54 def self.remove_assignment_for(plan_owner) LegacyPlanAssignmentApi.clear_override!( plan_owner, called_method_name: "PricingPlans::Assignment.remove_assignment_for" ) end |