Class: Sbuilder::Ial::Action::ModelBuilder

Inherits:
Object
  • Object
show all
Includes:
Fp::Compositable
Defined in:
lib/action/model_builder.rb

Instance Attribute Summary

Attributes included from Fp::Compositable

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Fp::Compositable

#Error, #Result, #_proc, #and_then, #error, included, #initialize, #isError, #isSuccess, #lwrap, #method_missing, #or_else, #pipe, #to_s

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sbuilder::Fp::Compositable

Class Method Details

.startObject

# @attr [Sbuilder::Ial::Action::Validator] validator attr_accessor :validator



9
10
11
12
13
# File 'lib/action/model_builder.rb', line 9

def self.start
  parser = ModelBuilder.new( Sbuilder::Ial::Model::Model.start )
  # parser.validator = Sbuilder::Ial::Action::Validator.start
  parser
end

Instance Method Details

#defineVo(vo) ⇒ Object


defineVo && defineVos



48
49
50
51
52
53
# File 'lib/action/model_builder.rb', line 48

def defineVo( vo )
  return if vo.nil?
  value.define( vo.type, vo.name, vo )
  vo
  # self
end

#defineVos(vos) ⇒ Object

self



54
55
56
57
# File 'lib/action/model_builder.rb', line 54

def defineVos( vos )
  defined = vos.map {  |vo|  defineVo( vo ) }
  # Sbuilder::Fp.Result( value )
end

#getModelObject



64
65
66
# File 'lib/action/model_builder.rb', line 64

def getModel
  value
end

#getModelBuiltResult(Sbuilder::Ial::Model::Model)

Returns model being build using ‘defineVo’.

Returns:



60
61
62
# File 'lib/action/model_builder.rb', line 60

def getModelBuilt
  Sbuilder::Fp.Result( getModel )
end

#updateVo(vo) ⇒ Object

Wrap result of ‘validator.updateVo’ to Result/Error compositable



21
22
23
24
25
26
27
28
29
30
# File 'lib/action/model_builder.rb', line 21

def updateVo( vo )
  Sbuilder::Fp.Result(vo)
  # begin
  #   updatedVoret = validator.updateVo( getModel, vo )
  #   ret = Sbuilder::Fp.Result( updatedVoret )
  # rescue PropertyError => err
  #   ret = Sbuilder::Fp.Error( err )
  # end
  # ret
end

#validateVo(vo) ⇒ Object

Currently no-operation



34
35
36
37
38
39
40
41
42
43
# File 'lib/action/model_builder.rb', line 34

def validateVo( vo )
  Sbuilder::Fp.Result(vo)
  # begin
  #   validationResult = validator.validateVo( getModel, vo )
  #   ret = validationResult ? Result( vo ) : Error( vo )
  # rescue PropertyError => err
  #   ret = Sbuilder::Fp.Error( err )
  # end
  # ret
end