Sha256: 89de81d2be85c39c3e1b3ead7f49fd7dacf103e393267b1373ef0f438c316803
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
# # Author: Seth Vargo <sethvargo@gmail.com> # # Copyright 2014 Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # module Falcore class Dumper::Base class << self def run(&block) block ? @run = block : @run || Proc.new end def validate(&block) block ? @validate = block : @validate || Proc.new end end # @return [Falcore::Config] attr_reader :config # @return [Falcore::Node::Master] attr_reader :master # # @param [Config] config # the config object # @param [Node::Master] master # the master node # def initialize(config, master) unless config.is_a?(Config) raise ArgumentError, "#{config.class} is not an Falcore::Config" end unless master.is_a?(Node::Master) raise ArgumenError, "#{config.class} is not an Falcore::Node::Master" end @config = config @master = master end # # Run this dumper. This method should be overridden in subclasses. # def run instance_eval(&self.class.validate) instance_eval(&self.class.run) end private # # Ensure the thing called in the block is not +nil+. # # @param [String] thing # the thing to check (used for the error message) # @param [Proc] block # the block to call # # @return [true] # def presence!(thing, &block) if block.call(self).nil? raise "Expected '#{thing}' to be set!" end true end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
falcore-0.2.0 | lib/falcore/dumpers/base.rb |
falcore-0.1.1 | lib/falcore/dumpers/base.rb |
falcore-0.1.0 | lib/falcore/dumpers/base.rb |