Sha256: ff160d4d4192057bded1174b7768fc38ff62f5a7e80232ebf6c66aa2e5ff8e43

Contents?: true

Size: 1.01 KB

Versions: 28

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8

module Adhearsion
  class CallController
    module MenuDSL
      class MatchCalculator

        class << self

          def build_with_pattern(pattern, match_payload, &block)
            class_for_pattern(pattern).new pattern, match_payload, &block
          end

          private

          def class_for_pattern(pattern)
            MenuDSL.const_get "#{pattern.class.name.camelize}MatchCalculator"
          end
        end

        attr_reader :pattern, :match_payload, :block

        def initialize(pattern, match_payload, &block)
          @pattern, @match_payload, @block = pattern, match_payload, block
        end

        protected

        def new_calculated_match(options)
          CalculatedMatch.new({:pattern => pattern, :match_payload => match_payload, :block => block}.merge(options))
        end

        def coerce_to_numeric(victim)
          victim.kind_of?(Numeric) ? victim : (victim.to_s =~ /^\d+$/ ? victim.to_s.to_i : nil )
        end

      end # class MatchCalculator
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
adhearsion-2.6.4 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.6.3 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.6.2 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.6.1 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.6.0 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.5.4 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.5.3 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.5.2 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.5.0 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.4.0 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.4.0.beta3 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.4.0.beta2 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.4.0.beta1 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.3.5 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.3.4 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.3.3 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.3.2 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.3.1 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.3.0 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb
adhearsion-2.2.1 lib/adhearsion/call_controller/menu_dsl/match_calculator.rb