Class: Hangry::RecipeAttributeCleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/hangry/recipe_attribute_cleaner.rb

Constant Summary collapse

MULTILINE_ATTRIBUTES =
[:instructions]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recipe) ⇒ RecipeAttributeCleaner

Returns a new instance of RecipeAttributeCleaner.



8
9
10
# File 'lib/hangry/recipe_attribute_cleaner.rb', line 8

def initialize(recipe)
  @recipe = recipe
end

Instance Attribute Details

#recipeObject (readonly)

Returns the value of attribute recipe.



6
7
8
# File 'lib/hangry/recipe_attribute_cleaner.rb', line 6

def recipe
  @recipe
end

Instance Method Details

#cleanObject



12
13
14
15
16
17
# File 'lib/hangry/recipe_attribute_cleaner.rb', line 12

def clean
  RECIPE_ATTRIBUTES.each do |attribute|
    recipe.public_send("#{attribute}=", clean_attribute(recipe, attribute))
  end
  recipe
end