Class: Fiveruns::Dash::Recipe
Defined Under Namespace
Classes: ConfigurationError
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_to(configuration) ⇒ Object
- #info ⇒ Object
-
#initialize(name, options = {}, &block) ⇒ Recipe
constructor
A new instance of Recipe.
-
#matches?(criteria) ⇒ Boolean
Currently :url is the only criteria; all other parts of the hash are settings to be passed on to the recipe.
Constructor Details
#initialize(name, options = {}, &block) ⇒ Recipe
Returns a new instance of Recipe.
22 23 24 25 26 27 28 |
# File 'lib/fiveruns/dash/recipe.rb', line 22 def initialize(name, = {}, &block) @name = name @options = @url = [:url] @block = block validate! end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/fiveruns/dash/recipe.rb', line 21 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/fiveruns/dash/recipe.rb', line 21 def @options end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
21 22 23 |
# File 'lib/fiveruns/dash/recipe.rb', line 21 def url @url end |
Class Method Details
.current ⇒ Object
11 12 13 |
# File 'lib/fiveruns/dash/recipe.rb', line 11 def self.current scope_stack.last end |
.in_scope(recipe) ⇒ Object
15 16 17 18 19 |
# File 'lib/fiveruns/dash/recipe.rb', line 15 def self.in_scope(recipe) scope_stack << recipe yield scope_stack.pop end |
.scope_stack ⇒ Object
7 8 9 |
# File 'lib/fiveruns/dash/recipe.rb', line 7 def self.scope_stack @scope_stack ||= [] end |
Instance Method Details
#==(other) ⇒ Object
48 49 50 |
# File 'lib/fiveruns/dash/recipe.rb', line 48 def ==(other) name == other.name && other. == end |
#add_to(configuration) ⇒ Object
30 31 32 33 34 |
# File 'lib/fiveruns/dash/recipe.rb', line 30 def add_to(configuration) self.class.in_scope(self) do @block.call(configuration) end end |
#info ⇒ Object
52 53 54 55 56 57 |
# File 'lib/fiveruns/dash/recipe.rb', line 52 def info { :name => name.to_s, :url => url.to_s } end |
#matches?(criteria) ⇒ Boolean
Currently :url is the only criteria; all other parts of the hash are settings to be passed on to the recipe
38 39 40 41 42 43 44 45 46 |
# File 'lib/fiveruns/dash/recipe.rb', line 38 def matches?(criteria) criteria.all? do |k, v| if [:url].include?(k) [k] == v else true end end end |