Class: ActiveScaffold::Config::Core::UserColumns
- Inherits:
-
Object
- Object
- ActiveScaffold::Config::Core::UserColumns
show all
- Includes:
- Enumerable
- Defined in:
- lib/active_scaffold/config/core.rb
Constant Summary
collapse
- DONT_DELEGATE =
i[add exclude add_association_columns _inheritable=].freeze
Instance Method Summary
collapse
Constructor Details
#initialize(columns) ⇒ UserColumns
Returns a new instance of UserColumns.
359
360
361
362
|
# File 'lib/active_scaffold/config/core.rb', line 359
def initialize(columns)
@global_columns = columns
@columns = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
384
385
386
387
388
389
390
|
# File 'lib/active_scaffold/config/core.rb', line 384
def method_missing(name, ...)
if respond_to_missing?(name, true)
@global_columns.send(name, ...)
else
super
end
end
|
Instance Method Details
364
365
366
|
# File 'lib/active_scaffold/config/core.rb', line 364
def [](name)
@columns[name.to_sym] || @global_columns[name]
end
|
376
377
378
379
380
381
382
|
# File 'lib/active_scaffold/config/core.rb', line 376
def each
return enum_for(:each) unless block_given?
@global_columns.each do |col|
yield self[col.name]
end
end
|
#override(name) ⇒ Object
368
369
370
371
372
373
374
|
# File 'lib/active_scaffold/config/core.rb', line 368
def override(name)
raise ArgumentError, "column '#{name}' doesn't exist" unless @global_columns[name]
(@columns[name.to_sym] ||= ActiveScaffold::DataStructures::ProxyColumn.new(@global_columns[name])).tap do |col|
yield col if block_given?
end
end
|
#respond_to_missing?(name, include_all = false) ⇒ Boolean
393
394
395
|
# File 'lib/active_scaffold/config/core.rb', line 393
def respond_to_missing?(name, include_all = false)
(DONT_DELEGATE.exclude?(name) && @global_columns.respond_to?(name, include_all)) || super
end
|