Class: Lipsiadmin::Ext::Configuration

Inherits:
Hash
  • Object
show all
Defined in:
lib/view/helpers/ext/configuration.rb

Overview

Ext configuration used by components

Generates: { name: 'name', handler: function(){ alert('Hello World') } }

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Configuration

:nodoc:



9
10
11
# File 'lib/view/helpers/ext/configuration.rb', line 9

def initialize(hash)#:nodoc:
  hash.each { |k,v| self[k] = v }
end

Instance Method Details

#to_s(indent = 1) ⇒ Object

Returns the configuration as a string. Optionally you can specify the indentation spaces.



15
16
17
18
19
20
21
# File 'lib/view/helpers/ext/configuration.rb', line 15

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