Sha256: 6b28bd17d0986466b7b7c7f8a048ffed23c0463297c28189d4c0e00dfb49b0d7

Contents?: true

Size: 728 Bytes

Versions: 16

Compression:

Stored size: 728 Bytes

Contents

# frozen_string_literal: true

module StimulusReflex
  class ReflexMethodInvocationPolicy
    attr_reader :arguments, :required_params, :optional_params

    def initialize(method, arguments)
      @arguments = arguments
      @required_params = method.parameters.select { |(kind, _)| kind == :req }
      @optional_params = method.parameters.select { |(kind, _)| kind == :opt }
    end

    def no_arguments?
      arguments.size == 0 && required_params.size == 0
    end

    def arguments?
      arguments.size >= required_params.size && arguments.size <= required_params.size + optional_params.size
    end

    def unknown?
      return false if no_arguments?
      return false if arguments?

      true
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
stimulus_reflex-3.5.3 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.rc4 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.rc3 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.rc2 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.rc1 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre10 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre9 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre8 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre7 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre6 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre5 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre4 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre3 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre2 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre1 lib/stimulus_reflex/policies/reflex_invocation_policy.rb
stimulus_reflex-3.5.0.pre0 lib/stimulus_reflex/policies/reflex_invocation_policy.rb