Sha256: 77e5fd48d537e01fa4696245ed9c5c1813a659f3ac69a1c5d561352a585079e5
Contents?: true
Size: 677 Bytes
Versions: 5
Compression:
Stored size: 677 Bytes
Contents
module Peony class Settings < Hash def method_missing(method, *args, &block) name = method.to_s key, punct = name[0..-2].to_sym, name[-1..-1] case punct when '=' self[key] = args.first != nil ? args.first : block when '?' include? key when '!' raise Error, "Setting :#{key} is not set" unless include?(key) evaluate self[key] else if include? method evaluate self[method] else block.call unless block.nil? end end end def evaluate(value) if value.is_a?(Proc) value.call else value end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
peony-0.1.9 | lib/peony/settings.rb |
peony-0.1.8 | lib/peony/settings.rb |
peony-0.1.6 | lib/peony/settings.rb |
peony-0.1.2 | lib/peony/settings.rb |
peony-0.1.1 | lib/peony/settings.rb |