boof / column_scope
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (1)
- Wiki (1)
- Graphs
-
Tree:
2728648
commit 2728648e199520be755207ff5f6c47b35b57b0a3
tree 6167b2c2c9feaa95321cfbf1660b7914130810c4
parent fc0e372a5f4d76b56a5df019646a4e6d4b010f0b
tree 6167b2c2c9feaa95321cfbf1660b7914130810c4
parent fc0e372a5f4d76b56a5df019646a4e6d4b010f0b
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | ||
| |
README.rdoc | ||
| |
Rakefile | ||
| |
init.rb | ||
| |
lib/ | ||
| |
test/ |
README.rdoc
ColumnScope
Selecting only specified columns can safe you resources and processing time.
I wrote this plugin because I do this all the time and I don’t want to cripple my code anymore.
ColumnScope is build on top of NamedScope so it only works with Ruby on Rails 2.1+.
Examples:
Item.selects(:name).proxy_options[:select] # => '"items"."name"' content = 'Foo Bar Baz' Item.create :name => 'foo', :value => 1, :content => content Item.create :name => 'bar', :value => 2, :content => content Item.create :name => 'baz', :value => 3, :content => content Item.selects(:name).values.all :order => 'id' # => %w[foo bar baz] # use a shortcut to retrieve values of name and content distinct Item.select_first :distinct_name__content # => ['foo', content] # without shortcut Item.selects(:name, :content).uniq!.values.all # => ['foo', content] # reject named columns in scope :a_named_scope and select only the values Item.a_named_scope.rejects(:content).values.all # => [[1, 'foo', 1], ...]
See test/column_scope_test.rb for more examples.
Install (rails):
$ script/plugin install git://github.com/boof/column_scope.git # alternativly: $ cd vendor/plugins $ git clone git://github.com/boof/column_scope.git
Copyright © 2008 Florian Aßmann, released under the MIT license

