Class: C2eCore::Drops::OrderRecipeDrop

Inherits:
BaseDrop
  • Object
show all
Includes:
Helpers::OrderConversions
Defined in:
/build/app/mailers/c2e_core/drops/order_recipe_drop.rb

Instance Method Summary collapse

Methods included from Helpers::OrderConversions

#converted_price, #format_price

Constructor Details

#initialize(order_recipe, order) ⇒ OrderRecipeDrop

Returns a new instance of OrderRecipeDrop.



8
9
10
11
12
# File '/build/app/mailers/c2e_core/drops/order_recipe_drop.rb', line 8

def initialize(order_recipe, order)
  super()
  @order_recipe = order_recipe
  @order = order
end

Instance Method Details

#childrenArray[OrderRecipeDrop]

Returns - Returns an array of side dish and cover order recipes for order recipe.

Returns:

  • (Array[OrderRecipeDrop])
    • Returns an array of side dish and cover order recipes for order recipe.



35
36
37
38
39
40
41
# File '/build/app/mailers/c2e_core/drops/order_recipe_drop.rb', line 35

def children
  stored_value __method__ do
    return [] unless @order_recipe.parent_id.nil?

    @order_recipe.children.to_a.map { |child_recipe| OrderRecipeDrop.new child_recipe, @order }
  end
end

#finalized_nameString

Returns - Name of recipe in moment of submitting order. E.g.: “200g Zbojnický steak”.

Returns:

  • (String)
    • Name of recipe in moment of submitting order. E.g.: “200g Zbojnický steak”



15
16
17
# File '/build/app/mailers/c2e_core/drops/order_recipe_drop.rb', line 15

def finalized_name
  @order_recipe.finalized_name_label
end

#noteString

Returns - Customers note for recipe. If not present, empty string is returned.

Returns:

  • (String)
    • Customers note for recipe. If not present, empty string is returned.



30
31
32
# File '/build/app/mailers/c2e_core/drops/order_recipe_drop.rb', line 30

def note
  @order_recipe.notes.info.first&.text.to_s
end

#priceFloat

Returns - Price of current recipe converted into order’s currency. E.g.: 78.

Returns:

  • (Float)
    • Price of current recipe converted into order’s currency. E.g.: 78



25
26
27
# File '/build/app/mailers/c2e_core/drops/order_recipe_drop.rb', line 25

def price
  converted_price @order_recipe.price
end

#recipeRecipeDrop

Returns - Returns recipe of order recipe as drop object.

Returns:

  • (RecipeDrop)
    • Returns recipe of order recipe as drop object.



20
21
22
# File '/build/app/mailers/c2e_core/drops/order_recipe_drop.rb', line 20

def recipe
  RecipeDrop.new @order_recipe.recipe
end