Class: ActiveScaffold::DataStructures::ProxyColumn
Constant Summary
collapse
- COPY_VARS =
%i[@list_ui @list_ui_options @show_ui @show_ui_options @search_ui @search_ui_options @search_joins].freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#<=>, #associated_number?, #attributes=, #cache_count?, #calculation?, #clear_link, #convert_to_native?, #description, #form_ui=, #includes=, #inplace_edit=, #label, #link, #list_ui, #list_ui=, #list_ui_options, #number?, #number_to_native, #placeholder, #required?, #search_joins, #search_joins=, #search_sql, #search_sql=, #search_ui, #search_ui=, #search_ui_options, #searchable?, #set_link, #show_blank_record?, #show_ui, #show_ui=, #show_ui_options, #sort, #sort=, #sort_by, #sortable?, #update_columns=
Constructor Details
Returns a new instance of ProxyColumn.
6
7
8
9
10
11
12
13
14
|
# File 'lib/active_scaffold/data_structures/proxy_column.rb', line 6
def initialize(column)
@column = column
(column.instance_variables & COPY_VARS).each do |var|
instance_variable_set(var, column.instance_variable_get(var))
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/active_scaffold/data_structures/proxy_column.rb', line 43
def method_missing(name, ...)
if respond_to_missing?(name, true)
@column.send(name, ...)
else
super
end
end
|
Instance Attribute Details
Returns the value of attribute options.
58
59
60
|
# File 'lib/active_scaffold/data_structures/proxy_column.rb', line 58
def options
@options
end
|
Returns the value of attribute params.
58
59
60
|
# File 'lib/active_scaffold/data_structures/proxy_column.rb', line 58
def params
@params
end
|
Class Method Details
.attr_accessor(*names) ⇒ Object
24
25
26
27
|
# File 'lib/active_scaffold/data_structures/proxy_column.rb', line 24
def self.attr_accessor(*names)
attr_reader(*names)
attr_writer(*names)
end
|
.attr_reader(*names) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/active_scaffold/data_structures/proxy_column.rb', line 16
def self.attr_reader(*names)
names.each do |name|
define_method name do
instance_variable_defined?(:"@#{name}") ? instance_variable_get(:"@#{name}") : @column.send(name)
end
end
end
|
.override_or_delegate(*names) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/active_scaffold/data_structures/proxy_column.rb', line 29
def self.override_or_delegate(*names)
location = caller_locations(1, 1).first
method_def = names.map do |name|
"def #{name}(...)
instance_variable_defined?(\"@#{name.to_s.gsub(/\?$/, '')}\") ? super : @column.send(\"#{name}\", ...)
end"
end
module_eval method_def.join(';'), location.path, location.lineno
names
end
|
Instance Method Details
#is_a?(klass) ⇒ Boolean
64
65
66
|
# File 'lib/active_scaffold/data_structures/proxy_column.rb', line 64
def is_a?(klass)
super || @column.is_a?(klass)
end
|
#respond_to_missing?(name, include_all = false) ⇒ Boolean
51
52
53
|
# File 'lib/active_scaffold/data_structures/proxy_column.rb', line 51
def respond_to_missing?(name, include_all = false)
(!name.match?(/[!=]$/) && @column.respond_to?(name, include_all)) || super
end
|