Module: Textus::VerbRegistry
- Defined in:
- lib/textus/verb_registry.rb
Defined Under Namespace
Classes: ArgSpec, VerbSpec
Constant Summary
collapse
- TYPE_MAP =
{
String => "string", Integer => "integer", Hash => "object",
Array => "array", :boolean => "boolean"
}.freeze
- VERBS =
{}
- POSITIONAL =
{}
Class Method Summary
collapse
Class Method Details
.contract_class_for(verb) ⇒ Object
60
|
# File 'lib/textus/verb_registry.rb', line 60
def self.contract_class_for(verb) = VERB_TO_CONTRACT[verb]
|
.contract_to_verb(klass) ⇒ Object
98
99
100
|
# File 'lib/textus/verb_registry.rb', line 98
def self.contract_to_verb(klass)
CONTRACT_TO_VERB[klass] || klass.name.split("::").last.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
end
|
.contract_to_verb!(klass) ⇒ Object
102
103
104
|
# File 'lib/textus/verb_registry.rb', line 102
def self.contract_to_verb!(klass)
CONTRACT_TO_VERB.fetch(klass) { raise "unknown contract class: #{klass}" }
end
|
.for(verb) ⇒ Object
56
|
# File 'lib/textus/verb_registry.rb', line 56
def self.for(verb) = VERBS[verb]
|
.positional_for(verb) ⇒ Object
57
|
# File 'lib/textus/verb_registry.rb', line 57
def self.positional_for(verb) = POSITIONAL[verb] || []
|
.register(spec) ⇒ Object
51
52
53
54
|
# File 'lib/textus/verb_registry.rb', line 51
def self.register(spec)
VERBS[spec.verb] = spec
POSITIONAL[spec.verb] = spec.args.select(&:positional).map(&:name)
end
|
.registered ⇒ Object
59
|
# File 'lib/textus/verb_registry.rb', line 59
def self.registered = VERBS.values
|
.summary_for(verb) ⇒ Object
58
|
# File 'lib/textus/verb_registry.rb', line 58
def self.summary_for(verb) = VERBS[verb]&.summary
|