Class: InferModel::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/infer_model/task.rb

Constant Summary collapse

FROMS =
{ csv: ::InferModel::From::CSV }.freeze
TOS =
{
  migration: ::InferModel::To::Migration,
  text: ::InferModel::To::Text,
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#from_argsObject (readonly)

Returns the value of attribute from_args.



11
12
13
# File 'lib/infer_model/task.rb', line 11

def from_args
  @from_args
end

#from_objectObject (readonly)

Returns the value of attribute from_object.



11
12
13
# File 'lib/infer_model/task.rb', line 11

def from_object
  @from_object
end

#from_optsObject (readonly)

Returns the value of attribute from_opts.



11
12
13
# File 'lib/infer_model/task.rb', line 11

def from_opts
  @from_opts
end

#to_argsObject (readonly)

Returns the value of attribute to_args.



11
12
13
# File 'lib/infer_model/task.rb', line 11

def to_args
  @to_args
end

#to_objectObject (readonly)

Returns the value of attribute to_object.



11
12
13
# File 'lib/infer_model/task.rb', line 11

def to_object
  @to_object
end

#to_optsObject (readonly)

Returns the value of attribute to_opts.



11
12
13
# File 'lib/infer_model/task.rb', line 11

def to_opts
  @to_opts
end

Class Method Details

.fromObject



34
# File 'lib/infer_model/task.rb', line 34

def from(...) = new.from(...)

.toObject



35
# File 'lib/infer_model/task.rb', line 35

def to(...) = new.to(...)

Instance Method Details

#callObject



29
30
31
# File 'lib/infer_model/task.rb', line 29

def call
  to_object.call(from_object.call(*from_args, **from_opts), *to_args, **to_opts)
end

#from(from_object, *args, **opts) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/infer_model/task.rb', line 13

def from(from_object, *args, **opts)
  @from_object = from_object
  @from_object = FROMS.fetch(from_object) if FROMS.key?(from_object)
  @from_args = args
  @from_opts = opts
  self
end

#to(to_object, *args, **opts) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/infer_model/task.rb', line 21

def to(to_object, *args, **opts)
  @to_object = to_object
  @to_object = TOS.fetch(to_object) if TOS.key?(to_object)
  @to_args = args
  @to_opts = opts
  self
end