From d6345ffd1723d440209bd88968440c76c3a8eabd Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Mon, 30 May 2016 23:28:54 +0200 Subject: [PATCH] add resource to filter table blocks i.e. get access to the original resource for more information and calls. --- lib/utils/filter.rb | 2 +- test/unit/utils/filter_table_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/utils/filter.rb b/lib/utils/filter.rb index aba781ff2..56916ac7d 100644 --- a/lib/utils/filter.rb +++ b/lib/utils/filter.rb @@ -40,7 +40,7 @@ module FilterTable end class Table - attr_reader :params + attr_reader :params, :resource def initialize(resource, params, filters) @resource = resource @params = params diff --git a/test/unit/utils/filter_table_test.rb b/test/unit/utils/filter_table_test.rb index 2faa0fca6..0696b3667 100644 --- a/test/unit/utils/filter_table_test.rb +++ b/test/unit/utils/filter_table_test.rb @@ -28,6 +28,13 @@ describe FilterTable do factory.must_be_kind_of FilterTable::Factory end + it 'retrieves the resource from all entries' do + factory.add_accessor(:where) + .add(:baz?) { |x| x.resource } + .connect(resource, :data) + instance.baz?.must_equal instance + end + describe 'when calling add_accessor' do it 'is chainable' do factory.add_accessor(:sth).must_equal factory