Class: PoolParty::Verify

Inherits:
Object show all
Defined in:
lib/poolparty/verification/verify.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Verify

Returns a new instance of Verify.



48
49
50
51
52
# File 'lib/poolparty/verification/verify.rb', line 48

def initialize(&block)
  ::PoolParty.require_user_directory "verifiers"
  
  instance_eval &block if block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a, &block) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/poolparty/verification/verify.rb', line 71

def method_missing m,*a,&block
  begin
    verifiers << constantize(m.to_s.capitalize, PoolParty::Verifiers).new(*a, &block)
  rescue 
    super
  end
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



47
48
49
# File 'lib/poolparty/verification/verify.rb', line 47

def host
  @host
end

Instance Method Details

#constantize(name, base_object = Monitors) ⇒ Object

Take a string and return a ruby object if a match is found in the base_objects namespace.



62
63
64
65
66
67
68
69
70
# File 'lib/poolparty/verification/verify.rb', line 62

def constantize(name, base_object=Monitors)
  begin
    const = base_object.constants.find{|cnst| cnst == name.camelcase }
    base_object.module_eval const
  rescue Exception => e
    puts "#{name.camelcase} is not defined. #{e}"
    nil
  end
end

#passing?Boolean

Check in with the verifiers and make sure they are all passing?

Returns:

  • (Boolean)


57
58
59
# File 'lib/poolparty/verification/verify.rb', line 57

def passing?
  verifiers.each {|v| raise "Not working" unless v.passing? }
end

#verifiersObject



54
# File 'lib/poolparty/verification/verify.rb', line 54

def verifiers;@verifiers ||= [];end