Sha256: 5d39f501cf362d6542a0a4a078bee678e3d37c0c7b7f4874609d7ca3a6da9ca0
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'json' require 'pathname' module Skippy::ConfigAccessors private def config_attr(*symbols, key: nil, type: nil) config_attr_reader(*symbols, key: key, type: type) config_attr_writer(*symbols, key: key, type: type) nil end def config_attr_reader(*symbols, key: nil, type: nil) self.class_eval { symbols.each { |symbol| raise TypeError unless symbol.is_a?(Symbol) define_method(symbol) { value = @config.get(key || symbol) value = type.new(value) if type && !value.is_a?(type) value } } } nil end def config_attr_writer(*symbols, key: nil, type: nil) self.class_eval { symbols.each { |symbol| raise TypeError unless symbol.is_a?(Symbol) symbol_set = "#{symbol}=".intern define_method(symbol_set) { |value| value = type.new(value) if type && !value.is_a?(type) @config.set(key || symbol, value) value } } } nil end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
skippy-0.2.0.a | lib/skippy/config_accessors.rb |