Class: SiteInspector::Endpoint::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/site-inspector/checks/check.rb

Constant Summary collapse

@@enabled =
true

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint) ⇒ Check

A check is an abstract class that takes an Endpoint object and is extended to preform the specific site inspector checks

It is automatically accessable within the endpoint object by virtue of extending the Check class



13
14
15
# File 'lib/site-inspector/checks/check.rb', line 13

def initialize(endpoint)
  @endpoint = endpoint
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



6
7
8
# File 'lib/site-inspector/checks/check.rb', line 6

def endpoint
  @endpoint
end

Class Method Details

.enabled=(value) ⇒ Object



48
49
50
# File 'lib/site-inspector/checks/check.rb', line 48

def enabled=(value)
  @@enabled = !!value
end

.enabled?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/site-inspector/checks/check.rb', line 44

def enabled?
  !!@@enabled
end

.nameObject



40
41
42
# File 'lib/site-inspector/checks/check.rb', line 40

def name
  to_s.split('::').last.downcase.to_sym
end

Instance Method Details

#hostObject



25
26
27
# File 'lib/site-inspector/checks/check.rb', line 25

def host
  request.base_url.host
end

#inspectObject



29
30
31
# File 'lib/site-inspector/checks/check.rb', line 29

def inspect
  "#<#{self.class} endpoint=\"#{response.effective_url}\">"
end

#nameObject



33
34
35
# File 'lib/site-inspector/checks/check.rb', line 33

def name
  self.class.name
end

#requestObject



21
22
23
# File 'lib/site-inspector/checks/check.rb', line 21

def request
  response.request
end

#responseObject



17
18
19
# File 'lib/site-inspector/checks/check.rb', line 17

def response
  endpoint.response
end