Method: ActiveModel::Serializer#initialize
- Defined in:
- lib/active_model/serializer.rb
#initialize(object, options = {}) ⇒ Serializer
scope_name is set as :current_user by default in the controller. If the instance does not have a method named scope_name, it defines the method so that it calls the scope.
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/active_model/serializer.rb', line 119 def initialize(object, = {}) self.object = object self. = self.root = [:root] self.scope = [:scope] return if !(scope_name = [:scope_name]) || respond_to?(scope_name) define_singleton_method scope_name, -> { scope } end |