Module: Stall::Sellable

Extended by:
ActiveSupport::Concern
Defined in:
lib/stall/sellable.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (private)



34
35
36
37
38
39
40
# File 'lib/stall/sellable.rb', line 34

def method_missing(name, *args, &block)
  if [:eot_price, :vat_rate].include?(name)
    send(:"default_#{ name }")
  else
    super
  end
end

Instance Method Details

#to_line_itemObject



11
12
13
14
15
16
17
18
# File 'lib/stall/sellable.rb', line 11

def to_line_item
  line_items.build(
    name: (respond_to?(:name) && name) || (respond_to?(:title) && title),
    unit_price: (respond_to?(:price) && price),
    unit_eot_price: eot_price,
    vat_rate: vat_rate,
  )
end

#vat_ratioObject



20
21
22
# File 'lib/stall/sellable.rb', line 20

def vat_ratio
  (vat_rate / 100.0) + 1
end