Class: ActsAsMessageable::Rails6

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/acts_as_messageable/rails6.rb

Instance Method Summary collapse

Constructor Details

#initialize(subject) ⇒ Rails6

Returns a new instance of Rails6.



11
12
13
# File 'lib/acts_as_messageable/rails6.rb', line 11

def initialize(subject)
  @subject = subject
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



51
52
53
# File 'lib/acts_as_messageable/rails6.rb', line 51

def method_missing(name, *args)
  @subject.send(name, *args) || super
end

Instance Method Details

#attr_accessible(*_args) ⇒ Object



19
# File 'lib/acts_as_messageable/rails6.rb', line 19

def attr_accessible(*_args); end

#default_scope(order_by) ⇒ Object



25
26
27
28
29
30
# File 'lib/acts_as_messageable/rails6.rb', line 25

def default_scope(order_by)
  @subject.send(:default_scope) do
    T.bind(self, ActiveRecord::Relation)
    order(order_by)
  end
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/acts_as_messageable/rails6.rb', line 59

def respond_to_missing?(method_name, include_private = false)
  %w[attr_accessible default_scope scoped update_attributes!].include?(method_name) || super
end

#scopedObject



35
36
37
# File 'lib/acts_as_messageable/rails6.rb', line 35

def scoped
  @subject.scope
end

#update_attributes!(*args) ⇒ Object



43
44
45
# File 'lib/acts_as_messageable/rails6.rb', line 43

def update_attributes!(*args)
  @subject.update!(*args)
end