Sha256: 71d76a38b03591d3661ecd00d799e802ce2ff8bd4244348d58c2dcb81882b712
Contents?: true
Size: 496 Bytes
Versions: 2
Compression:
Stored size: 496 Bytes
Contents
module BlockConfigurable class Configuration def add_config(param, default = nil) instance_eval %Q{ def #{param} @#{param} end def #{param}=(value) @#{param} = value end } instance_variable_set "@#{param}", default end def to_h instance_variables.reduce(Hash.new) do |a, e| a.merge(e[1..-1].to_sym => instance_variable_get(e)) end end alias_method :to_hash, :to_h end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
block_configurable-0.10.0 | lib/block_configurable/configuration.rb |
block_configurable-0.9.0 | lib/block_configurable/configuration.rb |