Sha256: 943978e9a7e8d912ac23a2959fa23312736bcdd8f8ac8f5e318e917824f72396
Contents?: true
Size: 1.52 KB
Versions: 3
Compression:
Stored size: 1.52 KB
Contents
# typed: strict # frozen_string_literal: true module ActsAsMessageable class Rails4 extend T::Sig delegate :update_attributes!, to: :@subject # @return [ActsAsMessageable::Rails4] api wrapper object # @param [ActiveRecord::Base] subject sig { params(subject: T.untyped).void } def initialize(subject) @subject = subject end # Empty method for Rails 4.x # @return [NilClass] # @param [Array] _args sig { params(_args: T.any(String, Symbol)).void } def attr_accessible(*_args); end # Default scope for Rails 4.x with block support # @return [Object] # @param [String, Symbol] order_by sig { params(order_by: T.any(String, Symbol)).returns(Object) } def default_scope(order_by) @subject.send(:default_scope) { T.unsafe(self).order(order_by) } end # Rename of the method # @return [Object] sig { returns(Object) } def scoped T.unsafe(@subject).scope end # @return [Object] # @param [Symbol] name # @param [Array] args sig { params(name: Symbol, args: T.untyped).returns(T.untyped) } def method_missing(name, *args) T.unsafe(@subject).send(name, *args) || super end # @return [Boolean] # @param [String] method_name # @param [Boolean] include_private sig { params(method_name: Symbol, include_private: T::Boolean).returns(T::Boolean) } def respond_to_missing?(method_name, include_private = false) %w[default_scope scoped attr_accessible].include?(method_name) || super end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
acts-as-messageable-1.0.2 | lib/acts_as_messageable/rails4.rb |
acts-as-messageable-1.0.1 | lib/acts_as_messageable/rails4.rb |
acts-as-messageable-1.0.0 | lib/acts_as_messageable/rails4.rb |