Sha256: c7354906053e7cf3b142c7c807d353ed18e94b73d2b2f35547accd546dc55071
Contents?: true
Size: 1.09 KB
Versions: 17
Compression:
Stored size: 1.09 KB
Contents
module Lipsiadmin module Ext # Ext configuration used by components # # Generates: { name: 'name', handler: function(){ alert('Hello World') } } # class Configuration < Hash def initialize(hash)#:nodoc: hash.each { |k,v| self[k] = v } end # Returns the configuration as a string. # Optionally you can specify the indentation spaces. def to_s(indent=1) return if self.empty? i = (" "*indent) s = self.size > 0 ? "\n" : " " r = "{#{s}" + self.collect { |k,v| "#{i*2}#{k}: #{s(v)}" if k != :var }.join(",#{s}") + "#{s}#{i if i.size > 1}}" return r =~ /\{\s*\}/ ? "" : r end private def javascript_object_for(object) case object when Configuration object.to_s(2) when Array "[" + object.collect { |o| s(o) }.join(",") + "]" else object.respond_to?(:to_json) ? object.to_json : object.inspect end end alias_method :s, :javascript_object_for end end end
Version data entries
17 entries across 17 versions & 1 rubygems