Class: Hecks::Bluebook::DSL::WorldBuilder
- Inherits:
-
Object
- Object
- Hecks::Bluebook::DSL::WorldBuilder
show all
- Includes:
- WordGate
- Defined in:
- lib/hecks/bluebook/dsl/world_builder.rb
Constant Summary
collapse
- GRAMMAR_CONTEXT =
"World"
Constants included
from WordGate
Hecks::Bluebook::DSL::WordGate::NOT_ADMITTED
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of WorldBuilder.
22
23
24
25
|
# File 'lib/hecks/bluebook/dsl/world_builder.rb', line 22
def initialize(domain)
@domain = domain
@settings = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(verb, *args, **kwargs, &block) ⇒ Object
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/hecks/bluebook/dsl/world_builder.rb', line 43
def method_missing(verb, *args, **kwargs, &block)
result = word_gate_dispatch(verb, args, kwargs, block)
return result unless result.equal?(WordGate::NOT_ADMITTED)
collector = SettingsCollector.new
collector.instance_eval(&block) if block
value = { adapter: args.first.to_s }.merge(kwargs).merge(collector.to_h)
@settings[verb.to_s] = value
@settings["#{verb}:#{args.first.to_s.downcase}"] = value
end
|
Class Method Details
.build(domain, &block) ⇒ Object
62
63
64
65
66
|
# File 'lib/hecks/bluebook/dsl/world_builder.rb', line 62
def self.build(domain, &block)
builder = new(domain)
builder.instance_eval(&block) if block
builder.build
end
|
Instance Method Details
#build ⇒ Object
56
57
58
59
60
|
# File 'lib/hecks/bluebook/dsl/world_builder.rb', line 56
def build
MetaValidator.call_world(
World.new(domain: @domain, realm: @realm, latest: @latest, settings: @settings)
)
end
|
#latest_impl(value) ⇒ Object
39
40
41
|
# File 'lib/hecks/bluebook/dsl/world_builder.rb', line 39
def latest_impl(value)
@latest = required(value, "latest version")
end
|
#realm_impl(value) ⇒ Object
RENAMED FROM realm/latest — item #13's full metaprogrammed
dispatch (slice 5). Neither bootstrap-reachable (checked
directly). Reached through WordGate#method_missing's new
word_gate_dispatch, called explicitly below since
WorldBuilder's own class-level method_missing (the
open-verb catch-all beneath this) always wins over the
module's — see word_gate.rb's own header for the full
mechanism.
35
36
37
|
# File 'lib/hecks/bluebook/dsl/world_builder.rb', line 35
def realm_impl(value)
@realm = required(value, "realm")
end
|
#respond_to_missing?(_name, _include_private = false) ⇒ Boolean
54
|
# File 'lib/hecks/bluebook/dsl/world_builder.rb', line 54
def respond_to_missing?(_name, _include_private = false) = true
|