Class: Eco::API::UseCases::BaseIO
- Defined in:
- lib/eco/api/usecases/base_io.rb,
lib/eco/api/usecases/base_io/chaining.rb,
lib/eco/api/usecases/base_io/validations.rb
Overview
Basic class to manage InputOuput for usecases
Direct Known Subclasses
Defined Under Namespace
Modules: Chaining, Validations
Constant Summary
Constants included from Eco::API::UseCases::BaseCase::Model
Eco::API::UseCases::BaseCase::Model::MODELS
Constants included from Eco::API::UseCases::BaseCase::Type
Eco::API::UseCases::BaseCase::Type::TYPES
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#model ⇒ Object
Returns the value of attribute model.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output ⇒ Object
Returns the value of attribute output.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes included from Language::AuxiliarLogger
Instance Method Summary collapse
-
#base ⇒ Eco::API::UseCases::BaseIO
Helper to obtain an
BaseIOobject from any child class. -
#initialize(session:, type: nil, model: nil, input: nil, data: nil, options: {}, output: nil, validate: true, people: nil) ⇒ BaseIO
constructor
A new instance of BaseIO.
- #io ⇒ Object
- #new(**kargs) ⇒ Eco::API::UseCases::BaseIO
-
#params(keyed: false, all: false) ⇒ Object
Helper to build a
Hashof symbol keys orArraywith params to do callbacks. -
#people ⇒ Object
backwards-compatibility.
Methods included from Chaining
Methods included from Language::AuxiliarLogger
Methods included from Language::Methods::DslAble
#evaluate, #method_missing, #respond_to_missing?
Methods included from Language::Klass::InheritableClassVars
#inheritable_attrs, #inheritable_class_vars, #inherited
Methods included from Language::Klass::Naming
#instance_variable_name, #to_constant
Methods included from Language::Klass::Hierarchy
Methods included from Language::Klass::Builder
Methods included from Language::Klass::Uid
Methods included from Language::Klass::Resolver
#class_resolver, #resolve_class
Methods included from Language::Klass::Const
#if_const, #redef_without_warning
Constructor Details
#initialize(session:, type: nil, model: nil, input: nil, data: nil, options: {}, output: nil, validate: true, people: nil) ⇒ BaseIO
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/eco/api/usecases/base_io.rb', line 26 def initialize( # rubocop:disable Lint/MissingSuper session:, type: nil, model: nil, input: nil, data: nil, options: {}, output: nil, validate: true, people: nil ) people ||= data # backwards-compatibility data ||= people self.type = type if type self.model = model if model @output = output @input = input @data = data @session = session @options = validate_args! if validate end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Eco::Language::Methods::DslAble
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
15 16 17 |
# File 'lib/eco/api/usecases/base_io.rb', line 15 def data @data end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
15 16 17 |
# File 'lib/eco/api/usecases/base_io.rb', line 15 def input @input end |
#model ⇒ Object
Returns the value of attribute model.
16 17 18 |
# File 'lib/eco/api/usecases/base_io.rb', line 16 def model @model end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/eco/api/usecases/base_io.rb', line 15 def @options end |
#output ⇒ Object
Returns the value of attribute output.
17 18 19 |
# File 'lib/eco/api/usecases/base_io.rb', line 17 def output @output end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
15 16 17 |
# File 'lib/eco/api/usecases/base_io.rb', line 15 def session @session end |
#type ⇒ Object
Returns the value of attribute type.
16 17 18 |
# File 'lib/eco/api/usecases/base_io.rb', line 16 def type @type end |
Instance Method Details
#base ⇒ Eco::API::UseCases::BaseIO
Helper to obtain an BaseIO object from any child class.
79 80 81 82 83 84 85 86 87 |
# File 'lib/eco/api/usecases/base_io.rb', line 79 def base kargs = params(keyed: true).merge({ type: type, model: model, output: output }).slice(*params_for_clone.keys) Eco::API::UseCases::BaseIO.new(**kargs) end |
#io ⇒ Object
used for DSLs
59 60 61 |
# File 'lib/eco/api/usecases/base_io.rb', line 59 def io self end |
#new(**kargs) ⇒ Eco::API::UseCases::BaseIO
91 92 93 |
# File 'lib/eco/api/usecases/base_io.rb', line 91 def new(**kargs) self.class.new(**params_for_clone, **kargs) end |
#params(keyed: false, all: false) ⇒ Object
order matters
Helper to build a Hash of symbol keys or Array with params to do callbacks.
97 98 99 100 101 102 103 104 |
# File 'lib/eco/api/usecases/base_io.rb', line 97 def params(keyed: false, all: false) kargs = {} kargs.merge!(input: input) if input_required? || all kargs.merge!(data: data) if data_required? || all kargs.merge!(session: session, options: ) keyed ? kargs : kargs.values end |
#people ⇒ Object
remove
backwards-compatibility
54 55 56 |
# File 'lib/eco/api/usecases/base_io.rb', line 54 def people data end |