Sha256: ba6ad098c37d14341b561d28d93f1ccbc7de0cccf8e2dc73aa481dbbc988f942

Contents?: true

Size: 573 Bytes

Versions: 6

Compression:

Stored size: 573 Bytes

Contents

module ConsoleUpdate
  
  # Adds a global scoped method, console_update(), which can be chained
  # to the end of any named scopes.
  # For example, if Url has a named scope :tagged_with:
  #   Url.tagged_with('physics').console_update
  def self.enable_named_scope  
    ActiveRecord::NamedScope::Scope.send :include, NamedScope
  end
  
  module NamedScope #:nodoc:
    def console_update(options={})
      records = send(:proxy_found)
      unless records.empty?
        records[0].class.console_update(records, options)
      else
        []
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
cldwalker-console_update-0.1.1 lib/console_update/named_scope.rb
console_update-0.1.6 lib/console_update/named_scope.rb
console_update-0.1.5 lib/console_update/named_scope.rb
console_update-0.1.4 lib/console_update/named_scope.rb
console_update-0.1.3 lib/console_update/named_scope.rb
console_update-0.1.2 lib/console_update/named_scope.rb