Skip to content

Commit

Permalink
Merge 202d119 into 0f5a275
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbutcher authored Oct 16, 2020
2 parents 0f5a275 + 202d119 commit 0890c70
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/frozen_record/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def method_missing(method_name, *args, &block)
super
end
end
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)

def delegate_to_class(*args, &block)
scoping { @klass.public_send(*args, &block) }
Expand Down
5 changes: 5 additions & 0 deletions spec/scope_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@
expect(countries.length).to be == 0
end

it 'is chainable with methods of the form `def method(*args, **kargs)' do
countries = Country.republics.continent_and_capital('Europe', capital: 'Paris')
expect(countries.length).to be == 1
end

it 'can be used with arrays' do
countries = Country.where(id: [1,2])
expect(countries.length).to be == 2
Expand Down
4 changes: 4 additions & 0 deletions spec/support/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def self.nato
where(nato: true)
end

def self.continent_and_capital(continent, capital:)
where(continent: continent, capital: capital)
end

def reverse_name
name.reverse
end
Expand Down

0 comments on commit 0890c70

Please sign in to comment.