Skip to content

Commit 36a0799

Browse files
committed
fix ActiveRecord::Base check
1 parent 70bc69a commit 36a0799

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/panko/impl/attributes_writer/creator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
module Panko::Impl
88
module AttributesWriter
99
def self.create(object)
10-
if defined?(ActiveRecord::Base) && object.is_a?(ActiveRecord::Base)
10+
if defined?(::ActiveRecord::Base) && object.is_a?(::ActiveRecord::Base)
1111
return ActiveRecord::Writer.new
1212
end
1313

lib/panko/serialization_descriptor.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,18 @@ def apply_association_filters(associations, only_filters, except_filters)
152152
end
153153
end
154154

155+
EMPTY_OBJECT = {}.freeze
156+
155157
def resolve_filters(options, filter)
156-
filters = options.fetch(filter, {})
157-
return filters, {} if filters.is_a? Array
158+
filters = options.fetch(filter, EMPTY_OBJECT)
159+
return filters, EMPTY_OBJECT if filters.is_a? Array
158160

159161
# hash filters looks like this
160162
# { instance: [:a], foo: [:b] }
161163
# which mean, for the current instance use `[:a]` as filter
162164
# and for association named `foo` use `[:b]`
163165

164-
return [], {} if filters.empty?
166+
return [], EMPTY_OBJECT if filters.empty?
165167

166168
attributes_filters = filters.fetch(:instance, [])
167169
association_filters = filters.except(:instance)

0 commit comments

Comments
 (0)