Sha256: 17b09a28427aac0b892fd15de2a75ac47afd5c950589a9dd252c55ad61a67f96
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
class Liza::UnitSettingsPart < Liza::Part insertion do def self.settings @settings ||= {} end def self.get key return settings[key] if settings.has_key? key found = nil for klass in ancestors break unless klass.respond_to? :settings if klass.settings.has_key? key found = klass.settings[key] break end end found = settings[key] = found.dup if found.is_a? Enumerable found end def self.set key, value settings[key] = value value end def self.add list, key = nil, value if key fetch(list) { Hash.new }[key] = value else fetch(list) { Set.new } << value end end def self.fetch key, &block x = get key x ||= set key, instance_eval(&block) x end def settings @settings ||= {} end def get key return settings[key] if settings.has_key? key self.class.get key end def set key, value settings[key] = value end def add list, key = nil, value if key fetch(list) { Hash.new }[key] = value else fetch(list) { Set.new } << value end end def fetch key, &block x = get key x ||= set key, eval(&block) x end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lizarb-1.0.4 | lib/liza/unit_parts/unit_settings_part.rb |