Module: Motor::ActiveRecordUtils::DefinedScopesExtension

Defined in:
lib/motor/active_record_utils/defined_scopes_extension.rb

Instance Method Summary collapse

Instance Method Details

#defined_scopesObject


18
19
20
# File 'lib/motor/active_record_utils/defined_scopes_extension.rb', line 18

def defined_scopes
  @__scopes__ || []
end

#inherited(subclass) ⇒ Object


6
7
8
9
10
# File 'lib/motor/active_record_utils/defined_scopes_extension.rb', line 6

def inherited(subclass)
  super

  subclass.instance_variable_set(:@__scopes__, subclass.superclass.instance_variable_get(:@__scopes__).dup)
end

#scope(name, _body) ⇒ Object


12
13
14
15
16
# File 'lib/motor/active_record_utils/defined_scopes_extension.rb', line 12

def scope(name, _body)
  (@__scopes__ ||= []) << name.to_sym

  super
end