Module: BillingLogic::CurrentStateMixin

Included in:
CurrentState
Defined in:
lib/billing_logic/current_state_mixin.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(clazz) ⇒ Object



3
4
5
6
# File 'lib/billing_logic/current_state_mixin.rb', line 3

def self.included(clazz)
  clazz.send(:attr_accessor, :profiles)
  clazz.send(:include, Enumerable)
end

Instance Method Details

#active_productsArray

Returns array with only BillingEngine::Client::Products belonging to the CurrentState’s active (i.e., enabled & active/pending) PaymentProfiles

Returns:

  • (Array)

    array of BillingEngine::Client::Products belonging to CurrentState’s “active” PaymentProfiles (i.e., where an ‘active’ PaymentProfile has #enabled => 1/true and #profile_status either ‘active’ or ‘pending’)



28
29
30
# File 'lib/billing_logic/current_state_mixin.rb', line 28

def active_products
  map { |profile| profile.active_products }.flatten
end

#current_productsArray

Returns array with only BillingEngine::Client::Products belonging to the CurrentState’s current (i.e., currently paid-up) PaymentProfiles

Returns:

  • (Array)

    array of BillingEngine::Client::Products belonging to CurrentState’s “current” PaymentProfiles (i.e., where paid_until_date >= Date.current )



18
19
20
# File 'lib/billing_logic/current_state_mixin.rb', line 18

def current_products
  map { |profile| profile.current_products }.flatten
end

#each(&block) ⇒ Object

Iterates through profiles, yielding each one-by-one to the block for processing



9
10
11
# File 'lib/billing_logic/current_state_mixin.rb', line 9

def each(&block)
  profiles.each(&block)
end