Class: Ext::Base
- Inherits:
-
Object
show all
- Includes:
- ActionView::Helpers::JavaScriptHelper
- Defined in:
- lib/ext/base.rb
Direct Known Subclasses
Code, Data::Connection, Data::HttpProxy, Data::JsonReader, Data::Store, Form::ComboBox, Form::DateField, Form::NumberField, Form::TextField, Function, Grid::ColumnModel, Grid::Grid, Grid::GridEditor, Tree::TreeLoader, Tree::TreePanel
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Base
Returns a new instance of Base.
18
19
20
|
# File 'lib/ext/base.rb', line 18
def initialize(*args)
@options = args.optionize(*fixed_args)
end
|
Class Method Details
.ext_patch(file_path) ⇒ Object
13
14
15
|
# File 'lib/ext/base.rb', line 13
def ext_patch(file_path)
Ext.patches[name] = File.read(file_path).gsub(/\A.*?\n__END__\n/m, '')
end
|
.to_json ⇒ Object
9
10
11
|
# File 'lib/ext/base.rb', line 9
def to_json
ext_class.to_s
end
|
Instance Method Details
#args ⇒ Object
51
52
53
54
55
|
# File 'lib/ext/base.rb', line 51
def args
array = fixed_values
array << camelize_keys(options) unless options.empty?
return array
end
|
#camelize_keys(hash) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/ext/base.rb', line 41
def camelize_keys(hash)
return hash unless hash.is_a?(Hash)
hash.inject({}) do |options, (key, value)|
key = key.to_s.camelize(:lower) if key.to_s.include?('_')
options[key.to_s] = value
options
end
end
|
#fixed_values ⇒ Object
22
23
24
|
# File 'lib/ext/base.rb', line 22
def fixed_values
fixed_args.map{|i| @options[i]}
end
|
#option(key) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/ext/base.rb', line 32
def option(key)
key = key.to_s.intern
if @options.has_key?(key)
@options[key]
else
__send__ key
end
end
|
#options ⇒ Object
26
27
28
29
30
|
# File 'lib/ext/base.rb', line 26
def options
returning opts = @options.dup do
fixed_args.each{|arg| opts.delete(arg)}
end
end
|
#to_json ⇒ Object
57
58
59
60
|
# File 'lib/ext/base.rb', line 57
def to_json
params = args.map(&:to_json).join(', ')
"new %s(%s)" % [ext_class, params]
end
|
#to_s ⇒ Object
62
63
64
|
# File 'lib/ext/base.rb', line 62
def to_s
to_json
end
|