Class: WorkflowTemplate::Validation::Builder::Proxy::Keyed

Inherits:
Proxy
  • Object
show all
Defined in:
lib/workflow_template/validation/builder/proxy.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, *args) ⇒ Keyed

Returns a new instance of Keyed.



111
112
113
114
# File 'lib/workflow_template/validation/builder/proxy.rb', line 111

def initialize(key, *args)
  @key = key.to_sym
  super(*args)
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



116
117
118
# File 'lib/workflow_template/validation/builder/proxy.rb', line 116

def key
  @key
end

Class Method Details

.instance(key, adapter, collection, name: nil, context: nil) ⇒ Object



98
99
100
101
# File 'lib/workflow_template/validation/builder/proxy.rb', line 98

def self.instance(key, adapter, collection, name: nil, context: nil)
  key = normalize_key(key)
  new key, adapter, collection, normalize_name(name) || key, normalize_context(context)
end

.normalize_key(key) ⇒ Object

Raises:



103
104
105
106
107
108
109
# File 'lib/workflow_template/validation/builder/proxy.rb', line 103

def self.normalize_key(key)
  return if key.nil?

  raise Error, 'Empty key' if key.empty?

  key.to_sym
end

Instance Method Details

#key?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/workflow_template/validation/builder/proxy.rb', line 118

def key?
  true
end

#validate(**opts, &block) ⇒ Object



122
123
124
# File 'lib/workflow_template/validation/builder/proxy.rb', line 122

def validate(**opts, &block)
  adapter.builder_class.new(self).validate(**opts, &block)
end