Class: BillerBotResource::Product

Inherits:
Resource
  • Object
show all
Defined in:
lib/biller_bot_resource/product.rb

Defined Under Namespace

Classes: Context

Instance Method Summary collapse

Methods inherited from Resource

#cache_key, config, configure, instantiate_collection, query_string, #save

Constructor Details

#initialize(*args) ⇒ Product

Returns a new instance of Product.



21
22
23
24
25
26
27
# File 'lib/biller_bot_resource/product.rb', line 21

def initialize(*args)
  super
  contexts.each do |c|
    c.product_id = id
    c.force_persisted # See comments on method
  end
end

Instance Method Details

#contextsObject



29
30
31
32
# File 'lib/biller_bot_resource/product.rb', line 29

def contexts
  @attributes[:contexts] ||= []
  @attributes[:contexts]
end

#root_context_for_account_id(account_id) ⇒ BillerBotResource::ProductContext|nil

Fetch the root product context for the given account ID.

Parameters:

  • account_id (Integer)

Returns:

  • (BillerBotResource::ProductContext|nil)


39
40
41
# File 'lib/biller_bot_resource/product.rb', line 39

def ()
  contexts.select { |c| c.type == "AccountProductContext" && c. ==  }.first
end