Skip to content

Commit af38b30

Browse files
kyreevesshishirmk
authored andcommitted
remove options param from Link class
1 parent 01477e9 commit af38b30

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

lib/fast_jsonapi/link.rb

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
module FastJsonapi
22
class Link
3-
attr_reader :key, :method, :conditional_proc
3+
attr_reader :key, :method
44

5-
def initialize(key:, method:, options: {})
5+
def initialize(key:, method:)
66
@key = key
77
@method = method
8-
@conditional_proc = options[:if]
98
end
109

1110
def serialize(record, serialization_params, output_hash)
12-
if include_link?(record, serialization_params)
13-
output_hash[key] = if method.is_a?(Proc)
14-
method.arity == 1 ? method.call(record) : method.call(record, serialization_params)
15-
else
16-
record.public_send(method)
17-
end
18-
end
19-
end
20-
21-
def include_link?(record, serialization_params)
22-
if conditional_proc.present?
23-
conditional_proc.call(record, serialization_params)
11+
output_hash[key] = if method.is_a?(Proc)
12+
method.arity == 1 ? method.call(record) : method.call(record, serialization_params)
2413
else
25-
true
14+
record.public_send(method)
2615
end
2716
end
2817
end
29-
end
18+
end

lib/fast_jsonapi/object_serializer.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,14 @@ def fetch_polymorphic_option(options)
239239
{}
240240
end
241241

242-
def link(link_name, link_method_name = nil, options = {}, &block)
242+
def link(link_name, link_method_name = nil, &block)
243243
self.data_links = {} if self.data_links.nil?
244244
link_method_name = link_name if link_method_name.nil?
245245
key = run_key_transform(link_name)
246246

247247
self.data_links[key] = Link.new(
248248
key: key,
249-
method: block || link_method_name,
250-
options: options
249+
method: block || link_method_name
251250
)
252251
end
253252

0 commit comments

Comments
 (0)