Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Feb 18, 2024
1 parent 1bdbb27 commit 86a4264
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 2 additions & 4 deletions lib/datagrid/drivers/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ def reverse_order(scope)

def greater_equal(scope, field, value)
scope.select do |object|
compare_value = object.public_send(field)
compare_value.respond_to?(:>=) && compare_value >= value
object.public_send(field) >= value
end
end

def less_equal(scope, field, value)
scope.select do |object|
compare_value = object.public_send(field)
compare_value.respond_to?(:<=) && compare_value <= value
object.public_send(field) <= value
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/datagrid/filters/base_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def header
def default(object)
default = self.options[:default]
if default.is_a?(Symbol)
object.public_send(default)
object.send(default)
elsif default.respond_to?(:call)
Datagrid::Utils.apply_args(object, &default)
else
Expand Down Expand Up @@ -173,7 +173,7 @@ def driver

def default_filter(value, scope, grid)
return nil if dummy?
if !driver.has_column?(scope, name) && scope.respond_to?(name)
if !driver.has_column?(scope, name) && scope.respond_to?(name, true)
scope.public_send(name, value)
else
default_filter_where(scope, value)
Expand Down
6 changes: 3 additions & 3 deletions spec/datagrid/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ class TestGrid < ScopeTestReport
class InspectTest
include Datagrid
scope {Entry}
filter(:created_at, :date, :range => true)
filter(:created_at, :date, range: true)
column(:name)
end

grid = InspectTest.new(:created_at => ['2014-01-01', '2014-08-05'], :descending => true, :order => 'name')
grid = InspectTest.new(created_at: ['2014-01-01', '2014-08-05'], descending: true, order: 'name')
expect(grid.inspect).to eq('#<InspectTest order: :name, descending: true, created_at: [Wed, 01 Jan 2014, Tue, 05 Aug 2014]>')
end
end
Expand Down Expand Up @@ -154,7 +154,7 @@ class EqualTest
end

it "has access to attributes" do
grid = test_report(:attribute_name => 'value') do
grid = test_report(attribute_name: 'value') do
scope {Entry}
datagrid_attribute :attribute_name
dynamic do
Expand Down

0 comments on commit 86a4264

Please sign in to comment.