Sha256: b8b8b773b4b27dbb1d53ef888d2f597e96902488f84f6395e076eddd1ed07256
Contents?: true
Size: 764 Bytes
Versions: 7
Compression:
Stored size: 764 Bytes
Contents
class Lbrt::Service::DSL::Context::Service include Lbrt::Utils::TemplateHelper REQUIRED_ATTRIBUTES = %w( settings ) def initialize(context, type, title, &block) @context = context.merge(:service_type => type, :service_title => title) @type = type @title = title @result = {} instance_eval(&block) end attr_reader :context def result REQUIRED_ATTRIBUTES.each do |name| unless @result.has_key?(name) raise "Service `#{@type}/#{@title}`: #{name} is not defined" end end @result end private def settings(value) unless value.is_a?(Hash) raise TypeError, "wrong argument type #{value.class}: #{value.inspect} (expected Hash)" end @result['settings'] = value end end
Version data entries
7 entries across 7 versions & 1 rubygems