Class: ActiveScaffold::Config::Core::UserColumns

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/active_scaffold/config/core.rb

Instance Method Summary collapse

Constructor Details

#initialize(columns) ⇒ UserColumns

Returns a new instance of UserColumns.



366
367
368
369
# File 'lib/active_scaffold/config/core.rb', line 366

def initialize(columns)
  @global_columns = columns
  @columns = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



383
384
385
386
387
388
389
# File 'lib/active_scaffold/config/core.rb', line 383

def method_missing(name, *args, &block)
  if @global_columns.respond_to?(name, true)
    @global_columns.send(name, *args, &block)
  else
    super
  end
end

Instance Method Details

#[](name) ⇒ Object



371
372
373
374
# File 'lib/active_scaffold/config/core.rb', line 371

def [](name)
  return nil unless @global_columns[name]
  @columns[name.to_sym] ||= CowProxy.wrap @global_columns[name]
end

#eachObject



376
377
378
379
380
381
# 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

#respond_to_missing?(name, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


391
392
393
# File 'lib/active_scaffold/config/core.rb', line 391

def respond_to_missing?(name, include_all = false)
  @global_columns.respond_to?(name, include_all) || super
end