Class: StimulusReflex::ReflexMethodInvocationPolicy
- Inherits:
-
Object
- Object
- StimulusReflex::ReflexMethodInvocationPolicy
- Defined in:
- lib/stimulus_reflex/policies/reflex_invocation_policy.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#optional_params ⇒ Object
readonly
Returns the value of attribute optional_params.
-
#required_params ⇒ Object
readonly
Returns the value of attribute required_params.
Instance Method Summary collapse
- #arguments? ⇒ Boolean
-
#initialize(method, arguments) ⇒ ReflexMethodInvocationPolicy
constructor
A new instance of ReflexMethodInvocationPolicy.
- #no_arguments? ⇒ Boolean
- #unknown? ⇒ Boolean
Constructor Details
#initialize(method, arguments) ⇒ ReflexMethodInvocationPolicy
Returns a new instance of ReflexMethodInvocationPolicy.
7 8 9 10 11 |
# File 'lib/stimulus_reflex/policies/reflex_invocation_policy.rb', line 7 def initialize(method, arguments) @arguments = arguments @required_params = method.parameters.select { |(kind, _)| kind == :req } @optional_params = method.parameters.select { |(kind, _)| kind == :opt } end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
5 6 7 |
# File 'lib/stimulus_reflex/policies/reflex_invocation_policy.rb', line 5 def arguments @arguments end |
#optional_params ⇒ Object (readonly)
Returns the value of attribute optional_params.
5 6 7 |
# File 'lib/stimulus_reflex/policies/reflex_invocation_policy.rb', line 5 def optional_params @optional_params end |
#required_params ⇒ Object (readonly)
Returns the value of attribute required_params.
5 6 7 |
# File 'lib/stimulus_reflex/policies/reflex_invocation_policy.rb', line 5 def required_params @required_params end |
Instance Method Details
#arguments? ⇒ Boolean
17 18 19 |
# File 'lib/stimulus_reflex/policies/reflex_invocation_policy.rb', line 17 def arguments? arguments.size >= required_params.size && arguments.size <= required_params.size + optional_params.size end |
#no_arguments? ⇒ Boolean
13 14 15 |
# File 'lib/stimulus_reflex/policies/reflex_invocation_policy.rb', line 13 def no_arguments? arguments.size == 0 && required_params.size == 0 end |
#unknown? ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/stimulus_reflex/policies/reflex_invocation_policy.rb', line 21 def unknown? return false if no_arguments? return false if arguments? true end |