Class: Inferno::Entities::Input
- Inherits:
-
Object
- Object
- Inferno::Entities::Input
- Defined in:
- lib/inferno/entities/input.rb
Overview
This class represents an Input for a runnable.
Constant Summary collapse
- ATTRIBUTES =
[ :name, :title, :description, :type, :default, :optional, :options, :locked, :value ].freeze
- UNINHERITABLE_ATTRIBUTES =
These attributes require special handling when merging input definitions.
[ # Locking an input only has meaning at the level it is locked. # Consider: # - ParentGroup # - Group 1, input :a # - Group 2, input :a, locked: true # The input 'a' should be only be locked when running Group 2 in # isolation. It should not be locked when running Group 1 or the # ParentGroup. :locked, # Input type is sometimes only a UI concern (e.g. text vs. textarea), so # it is common to not redeclare the type everywhere it's used and needs # special handling to avoid clobbering the type with the default (text) # type. :type ].freeze
- INHERITABLE_ATTRIBUTES =
These are the attributes that can be directly copied when merging a runnable’s input with the input of one of its children.
(ATTRIBUTES - UNINHERITABLE_ATTRIBUTES).freeze
- MERGEABLE_ATTRIBUTES =
These are the attributes that can be directly copied when merging a runnable’s input with an input configuration.
(ATTRIBUTES - [:type]).freeze
Instance Method Summary collapse
-
#==(other) ⇒ Object
-
#initialize(**params) ⇒ Input
constructor
A new instance of Input.
-
#to_hash ⇒ Object
Constructor Details
#initialize(**params) ⇒ Input
Returns a new instance of Input.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/inferno/entities/input.rb', line 48 def initialize(**params) bad_params = params.keys - ATTRIBUTES raise Exceptions::UnknownAttributeException.new(bad_params, self.class) if bad_params.present? params .compact .each { |key, value| send("#{key}=", value) } self.name = name.to_s if params[:name].present? end |
Instance Method Details
#==(other) ⇒ Object
115 116 117 118 119 |
# File 'lib/inferno/entities/input.rb', line 115 def ==(other) return false unless other.is_a? Input ATTRIBUTES.all? { |attribute| send(attribute) == other.send(attribute) } end |
#to_hash ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/inferno/entities/input.rb', line 106 def to_hash ATTRIBUTES.each_with_object({}) do |attribute, hash| value = send(attribute) next if value.nil? hash[attribute] = value end end |