Class: ParamsReady::AbstractBuilder
Defined Under Namespace
Modules: HavingArelTable, HavingModel, HavingValue
Class Method Summary
collapse
-
.define_parameter(type, *args, **opts, &block) ⇒ Object
-
.define_registered_parameter(name, *args, **opts, &block) ⇒ Object
-
.instance(*args, **opts) ⇒ Object
-
.register(name) ⇒ Object
-
.resolve(input, *args, **opts, &block) ⇒ Object
Instance Method Summary
collapse
human_string, registry
Constructor Details
Returns a new instance of AbstractBuilder.
57
58
59
|
# File 'lib/params_ready/builder.rb', line 57
def initialize(definition)
@definition = definition
end
|
Class Method Details
.define_parameter(type, *args, **opts, &block) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/params_ready/builder.rb', line 31
def self.define_parameter(type, *args, **opts, &block)
builder_class = builder(type)
builder = builder_class.instance(*args, **opts)
builder.include(&block) unless block.nil?
builder.build
end
|
.define_registered_parameter(name, *args, **opts, &block) ⇒ Object
38
39
40
41
|
# File 'lib/params_ready/builder.rb', line 38
def self.define_registered_parameter(name, *args, **opts, &block)
full_name = "define_#{name}"
send(full_name, *args, **opts, &block)
end
|
.instance(*args, **opts) ⇒ Object
51
52
53
|
# File 'lib/params_ready/builder.rb', line 51
def self.instance(*args, **opts)
new *args, **opts
end
|
.register(name) ⇒ Object
27
28
29
|
# File 'lib/params_ready/builder.rb', line 27
def self.register(name)
register_builder(name, self)
end
|
.resolve(input, *args, **opts, &block) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/params_ready/builder.rb', line 43
def self.resolve(input, *args, **opts, &block)
if input.is_a? Parameter::AbstractDefinition
input
else
define_registered_parameter(input, *args, **opts, &block)
end
end
|
Instance Method Details
#build ⇒ Object
72
73
74
75
|
# File 'lib/params_ready/builder.rb', line 72
def build
@definition.finish
@definition
end
|
#fetch ⇒ Object
66
67
68
69
70
|
# File 'lib/params_ready/builder.rb', line 66
def fetch
d = @definition
@definition = nil
d
end
|
#include(&block) ⇒ Object
61
62
63
64
|
# File 'lib/params_ready/builder.rb', line 61
def include(&block)
instance_eval(&block)
self
end
|
#open? ⇒ Boolean
77
78
79
80
81
82
|
# File 'lib/params_ready/builder.rb', line 77
def open?
return false if @definition.nil?
return false if @definition.frozen?
true
end
|