Skip to content

Commit 622f38d

Browse files
committed
custom resource scope, add scope assert_valid_keys
1 parent 154f157 commit 622f38d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/liquid-rails/drops/collection_drop.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def self.scope(*scope_names)
2929
delegate :total_count, :total_pages, to: :objects
3030

3131
def initialize(objects, options={})
32-
options.assert_valid_keys(:with)
32+
options.assert_valid_keys(:with, :scope)
3333

3434
@objects = objects
3535
@drop_class_name = options[:with]

lib/liquid-rails/drops/drop.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ def self.drop_class_for(resource)
3939
end
4040

4141
# Create a drop instance when it cannot be inferred.
42-
def self.dropify(resource, options={})
43-
binding.pry
42+
def self.dropify(wealth, options={})
4443
drop_class = if options[:class_name]
4544
options[:class_name].constantize
4645
else
47-
drop_class_for(resource)
46+
drop_class_for(wealth)
4847
end
49-
# eval "resource.#{options[:scope]}"
48+
resource = options[:scope].nil? ? wealth : eval("wealth.#{options[:scope]}")
5049
drop_class.new(resource, options.except(:class_name))
5150
end
5251

0 commit comments

Comments
 (0)