Sha256: 8379b5486abc5c5af4c9fc426c90a23890710e76c379d947eb13e0143f4fd29a

Contents?: true

Size: 1019 Bytes

Versions: 24

Compression:

Stored size: 1019 Bytes

Contents

module Intercom
  module Traits

    # Allows us to have one class level method missing handler across all entities
    # which can dispatch to the appropriate function based on the method name
    module GenericHandlerBinding

      module ClassMethods
        def method_missing(method_sym, *arguments, &block)
          if respond_to? :generic_tag and GenericHandlers::Tag.handles_method?(method_sym)
            return generic_tag(method_sym, *arguments, block)
          elsif respond_to? :generic_tag_find_all and GenericHandlers::TagFindAll.handles_method?(method_sym)
            return generic_tag_find_all(method_sym, *arguments, block)
          elsif respond_to? :generic_count and GenericHandlers::Count.handles_method?(method_sym)
            return generic_count(method_sym, *arguments, block)
          end
          super
        rescue Intercom::NoMethodMissingHandler
          super
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end

    end
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
cogniteev-intercom-2.5.4 lib/intercom/traits/generic_handler_binding.rb
intercom-2.5.4 lib/intercom/traits/generic_handler_binding.rb
intercom-2.4.4 lib/intercom/traits/generic_handler_binding.rb
intercom-2.4.3 lib/intercom/traits/generic_handler_binding.rb
intercom-2.4.2 lib/intercom/traits/generic_handler_binding.rb
intercom-2.4.1 lib/intercom/traits/generic_handler_binding.rb
intercom-2.4.0 lib/intercom/traits/generic_handler_binding.rb
intercom-2.3.0 lib/intercom/traits/generic_handler_binding.rb
intercom-2.2.4 lib/intercom/traits/generic_handler_binding.rb
intercom-2.2.3 lib/intercom/traits/generic_handler_binding.rb
intercom-2.2.2 lib/intercom/traits/generic_handler_binding.rb
intercom-2.2.1 lib/intercom/traits/generic_handler_binding.rb
intercom-2.2.0 lib/intercom/traits/generic_handler_binding.rb
intercom-2.1.6 lib/intercom/traits/generic_handler_binding.rb
intercom-2.1.5 lib/intercom/traits/generic_handler_binding.rb
intercom-2.1.4 lib/intercom/traits/generic_handler_binding.rb
intercom-2.1.3 lib/intercom/traits/generic_handler_binding.rb
intercom-2.1.2 lib/intercom/traits/generic_handler_binding.rb
intercom-2.1.1 lib/intercom/traits/generic_handler_binding.rb
intercom-2.1.0 lib/intercom/traits/generic_handler_binding.rb