Class: Freenom::Expecting::ExpectingContext

Inherits:
Object
  • Object
show all
Defined in:
lib/freenom/dns/others/expecting.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExpectingContext

Returns a new instance of ExpectingContext.



8
9
10
# File 'lib/freenom/dns/others/expecting.rb', line 8

def initialize
  @eithers = []
end

Instance Attribute Details

#eithersObject

Returns the value of attribute eithers.



6
7
8
# File 'lib/freenom/dns/others/expecting.rb', line 6

def eithers
  @eithers
end

Instance Method Details

#either(name, &block) ⇒ Object



12
13
14
# File 'lib/freenom/dns/others/expecting.rb', line 12

def either(name, &block)
  @eithers << [name, block]
end

#execute(context) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/freenom/dns/others/expecting.rb', line 16

def execute(context)
  @eithers.each do |either|
    name = either[0]
    block = either[1]

    return name if context.instance_eval(&block)
  end
  nil
end