./lib/overload/hash.rb in lux-fw-0.1.35 vs ./lib/overload/hash.rb in lux-fw-0.2.1
- old
+ new
@@ -8,11 +8,11 @@
def h_wia
HashWithIndifferentAccess.new(self)
end
def tag node=nil, text=nil
- Lux::Helper::HtmlTag.build self, node, text
+ HtmlTagBuilder.build self, node, text
end
def to_struct name=nil
name ||= ToStructGeneric
Struct.new(name, *keys).new(*values)
@@ -72,24 +72,17 @@
hash.default_proc = default_proc if default_proc
replace(hash)
omit
end
- # full dinmaic option, slow
- # def to_opts! *keys
- # self.keys.each { |key| raise 'Hash key :%s is not allowed!' % key unless keys.include?(key) }
-
- # template = Class.new
- # keys.each { |key| template.send(:attr_accessor, key) }
-
- # klass = template.new
- # keys.map { |key| klass.send '%s=' % key, self[key] }
- # klass
- # end
def to_opts! *keys
self.keys.each { |key| raise 'Hash key :%s is not allowed!' % key unless keys.include?(key) }
DynamicClass.new keys
.inject({}) { |_, key| _[key] = self[key]; _ }
+ end
+
+ def pretty_generate
+ JSON.pretty_generate(self).gsub(/"([\w\-]+)":/) { %["#{$1.yellow}":] }
end
end