Skip to content
This repository
Browse code

adding support for passing block to scope_builder

  • Loading branch information...
commit 5d7c4048eb1babec9b930f9b21250e9b99d0987b 1 parent ca93190
Ryan Bates authored
5 Manifest
@@ -3,11 +3,12 @@ lib/scope_builder/builder.rb
3 3 lib/scope_builder/model_additions.rb
4 4 lib/scope_builder.rb
5 5 LICENSE
  6 +Manifest
6 7 README
  8 +spec/models/product.rb
7 9 spec/scope_builder/builder_spec.rb
8   -spec/scope_builder/model_additions_spec.rb
9 10 spec/spec_helper.rb
  11 +spec/test.sqlite3
10 12 tasks/deployment.rake
11 13 tasks/spec.rake
12 14 TODO
13   -Manifest
4 lib/scope_builder/model_additions.rb
... ... @@ -1,7 +1,9 @@
1 1 module ScopeBuilder
2 2 module ModelAdditions
3 3 def scope_builder
4   - Builder.new(scoped({}))
  4 + builder = Builder.new(scoped({}))
  5 + yield(builder) if block_given?
  6 + builder
5 7 end
6 8 end
7 9 end
58 scope-builder.gemspec
... ... @@ -0,0 +1,58 @@
  1 +
  2 +# Gem::Specification for Scope-builder-0.1.0
  3 +# Originally generated by Echoe
  4 +
  5 +Gem::Specification.new do |s|
  6 + s.name = %q{scope-builder}
  7 + s.version = "0.1.0"
  8 +
  9 + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
  10 + s.authors = ["Ryan Bates"]
  11 + s.date = %q{2008-06-26}
  12 + s.description = %q{Build up named scopes conditionally.}
  13 + s.email = %q{ryan (at) railscasts (dot) com}
  14 + s.extra_rdoc_files = ["CHANGELOG", "lib/scope_builder/builder.rb", "lib/scope_builder/model_additions.rb", "lib/scope_builder.rb", "LICENSE", "README", "tasks/deployment.rake", "tasks/spec.rake", "TODO"]
  15 + s.files = ["CHANGELOG", "lib/scope_builder/builder.rb", "lib/scope_builder/model_additions.rb", "lib/scope_builder.rb", "LICENSE", "Manifest", "README", "spec/models/product.rb", "spec/scope_builder/builder_spec.rb", "spec/spec_helper.rb", "spec/test.sqlite3", "tasks/deployment.rake", "tasks/spec.rake", "TODO", "scope-builder.gemspec"]
  16 + s.has_rdoc = true
  17 + s.homepage = %q{http://github.com/ryanb/scope-builder}
  18 + s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Scope-builder", "--main", "README"]
  19 + s.require_paths = ["lib"]
  20 + s.rubyforge_project = %q{scope-builder}
  21 + s.rubygems_version = %q{1.2.0}
  22 + s.summary = %q{Build up named scopes conditionally.}
  23 +
  24 + if s.respond_to? :specification_version then
  25 + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
  26 + s.specification_version = 2
  27 +
  28 + if current_version >= 3 then
  29 + else
  30 + end
  31 + else
  32 + end
  33 +end
  34 +
  35 +
  36 +# # Original Rakefile source (requires the Echoe gem):
  37 +#
  38 +# require 'rubygems'
  39 +# require 'rake'
  40 +#
  41 +# begin
  42 +# require 'echoe'
  43 +#
  44 +# Echoe.new('scope-builder', '0.1.0') do |p|
  45 +# p.summary = "Build up named scopes conditionally."
  46 +# p.description = "Build up named scopes conditionally."
  47 +# p.url = "http://github.com/ryanb/scope-builder"
  48 +# p.author = 'Ryan Bates'
  49 +# p.email = "ryan (at) railscasts (dot) com"
  50 +# p.ignore_pattern = ["script/*"]
  51 +# end
  52 +#
  53 +# rescue LoadError => boom
  54 +# puts "You are missing a dependency required for meta-operations on this gem."
  55 +# puts "#{boom.to_s.capitalize}."
  56 +# end
  57 +#
  58 +# Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
4 spec/scope_builder/builder_spec.rb
@@ -43,4 +43,8 @@
43 43 it "should respond to enumerable methods like each_with_index" do
44 44 @builder.should respond_to(:each_with_index)
45 45 end
  46 +
  47 + it "should be able to build up scope in block" do
  48 + Product.scope_builder { |b| b.released }.all.should == Product.released.all
  49 + end
46 50 end

0 comments on commit 5d7c404

Please sign in to comment.
Something went wrong with that request. Please try again.