Sha256: 90722f7c5ee1e779e743593a244509c133a4ed6b22a0139794636d0fe0323997
Contents?: true
Size: 1.07 KB
Versions: 8
Compression:
Stored size: 1.07 KB
Contents
module Fiveruns::Dash class Recipe class ConfigurationError < ::ArgumentError; end def self.scope_stack @scope_stack ||= [] end def self.current scope_stack.last end def self.in_scope(recipe) scope_stack << recipe yield scope_stack.pop end attr_reader :name, :url, :options def initialize(name, options = {}, &block) @name = name @options = options @url = options[:url] @block = block validate! end def add_to(configuration) self.class.in_scope self do @block.call(configuration) end end def matches?(criteria) criteria.all? { |k, v| options[k] == v } end def ==(other) name == other.name && other.options == options end def info { :name => name.to_s, :url => url.to_s } end ####### private ####### def validate! unless @url raise ConfigurationError, "Recipe requires :url option" end end end end
Version data entries
8 entries across 8 versions & 1 rubygems