Class: PoolParty::Verify

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

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Verify

Returns a new instance of Verify.



42
43
44
45
46
# File 'lib/poolparty/verification/verify.rb', line 42

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



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

def method_missing m,*a,&block
  begin
    verifiers << constantize(m.to_s.capitalize, PoolParty::Verifiers).new(*a, &block)
  rescue 
    super
  end
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.



56
57
58
59
60
61
62
63
64
# File 'lib/poolparty/verification/verify.rb', line 56

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)


51
52
53
# File 'lib/poolparty/verification/verify.rb', line 51

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

#verifiersObject



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

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