Module: Peck::Rails::Controller::Fixtures

Defined in:
lib/peck_on_rails.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments, &block) ⇒ Object

Filter calls to fixture methods so we can use them in the context definition



99
100
101
102
103
104
105
106
# File 'lib/peck_on_rails.rb', line 99

def method_missing(method, *arguments, &block)
  if known_fixture?(method)
    arguments = arguments.map { |a| a.inspect }
    ::Peck::Rails::Controller::LazyValue.new("#{method}(#{arguments.join(', ')})")
  else
    super
  end
end

Instance Method Details

#known_fixture?(name) ⇒ Boolean

Returns true when the passed name is a known table, we assume known tables also have fixtures

Returns:

  • (Boolean)


94
95
96
# File 'lib/peck_on_rails.rb', line 94

def known_fixture?(name)
  respond_to?(:fixture_table_names) && fixture_table_names.include?(name.to_s)
end