Class: Punchfork::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/punchfork/search.rb

Overview

Wrapper for search results providing dot syntax

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Search

Returns a new instance of Search.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/punchfork/search.rb', line 6

def initialize(*args)
  @hash = args[0]
  @attributes = {}
  
  @hash.each do |k, v|
    instance_variable_set("@#{k}", v)
    self.class.class_eval{attr_reader k}
    @attributes[k] = v
  end
  
  @recipes = @recipes.map{ |recipe_hash| recipe = Recipe.new(recipe_hash) }
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



19
20
21
# File 'lib/punchfork/search.rb', line 19

def attributes
  @attributes
end

Instance Method Details

#[](key) ⇒ Object



21
22
23
# File 'lib/punchfork/search.rb', line 21

def [](key)
  @hash[key]
end