Class: Zaikio::Hub::Subscription
- Defined in:
- lib/zaikio/hub/subscription.rb
Instance Method Summary collapse
- #activate! ⇒ Object
- #increment_usage_by!(usage, by = 1) ⇒ Object
-
#initialize(attributes = {}) ⇒ Subscription
constructor
A new instance of Subscription.
Constructor Details
#initialize(attributes = {}) ⇒ Subscription
Returns a new instance of Subscription.
14 15 16 17 18 19 20 21 22 |
# File 'lib/zaikio/hub/subscription.rb', line 14 def initialize(attributes = {}) if attributes["subscriber_id"] super(attributes.merge( "id" => "#{attributes['subscriber_type']}-#{attributes['subscriber_id']}" )) else super end end |
Instance Method Details
#activate! ⇒ Object
24 25 26 |
# File 'lib/zaikio/hub/subscription.rb', line 24 def activate! update(status: "active") end |
#increment_usage_by!(usage, by = 1) ⇒ Object
28 29 30 |
# File 'lib/zaikio/hub/subscription.rb', line 28 def increment_usage_by!(usage, by = 1) update(increment_usages_in_current_billing_period: { usage => by }) end |