Module: JSONAPI::Callbacks::ClassMethods

Defined in:
lib/jsonapi/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#define_jsonapi_resources_callbacks(*callbacks) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jsonapi/callbacks.rb', line 13

def define_jsonapi_resources_callbacks(*callbacks)
  options = callbacks.extract_options!
  options = {
    only: [:before, :around, :after]
  }.merge!(options)

  types = Array(options.delete(:only))

  callbacks.each do |callback|
    define_callbacks(callback, options)

    types.each do |type|
      send("_define_#{type}_callback", self, callback)
    end
  end
end