Class: Validate::AST::Rules::Pending

Inherits:
Constraint show all
Includes:
MonitorMixin
Defined in:
lib/validate/ast.rb

Instance Method Summary collapse

Methods inherited from Constraint

create_class, inherited

Constructor Details

#initialize(name, args, block, caller) ⇒ Pending

Returns a new instance of Pending.



194
195
196
197
198
199
200
201
202
203
# File 'lib/validate/ast.rb', line 194

def initialize(name, args, block, caller)
  @name = name
  @args = args
  @block = block
  @caller = caller
  @constraint = nil

  extend SingleForwardable
  mon_initialize
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



225
226
227
# File 'lib/validate/ast.rb', line 225

def method_missing(method, *args)
  load_constraint { return NameError }.__send__(method, *args)
end

Instance Method Details

#==(other) ⇒ Object



221
222
223
# File 'lib/validate/ast.rb', line 221

def ==(other)
  load_constraint { return false } == other
end

#inspectObject



217
218
219
# File 'lib/validate/ast.rb', line 217

def inspect
  load_constraint { return "[pending #{@name}]" }.inspect
end

#nameObject



205
206
207
# File 'lib/validate/ast.rb', line 205

def name
  load_constraint { return @name }.name
end

#respond_to_missing?(method, pvt = false) ⇒ Boolean

Returns:

  • (Boolean)


229
230
231
# File 'lib/validate/ast.rb', line 229

def respond_to_missing?(method, pvt = false)
  load_constraint { return false }.__send__(:respond_to_missing?, method, pvt)
end

#to_sObject



213
214
215
# File 'lib/validate/ast.rb', line 213

def to_s
  load_constraint { return "[pending #{@name}]" }.to_s
end

#valid?(value, ctx = Constraints::ValidationContext.none) ⇒ Boolean

Returns:

  • (Boolean)


209
210
211
# File 'lib/validate/ast.rb', line 209

def valid?(value, ctx = Constraints::ValidationContext.none)
  load_constraint { throw(:pending, true) }.valid?(value, ctx)
end