Class: Moku::Sites::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/moku/sites/scope.rb

Overview

Scopes are used to create a list of hosts from a Sites object.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, callable) ⇒ Scope

Returns a new instance of Scope.


29
30
31
32
# File 'lib/moku/sites/scope.rb', line 29

def initialize(identifier, callable)
  @identifier = identifier
  @callable = callable
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier


34
35
36
# File 'lib/moku/sites/scope.rb', line 34

def identifier
  @identifier
end

Class Method Details

.allObject


9
10
11
# File 'lib/moku/sites/scope.rb', line 9

def self.all
  new(:all, proc {|sites| sites.hosts })
end

.each_siteObject


13
14
15
# File 'lib/moku/sites/scope.rb', line 13

def self.each_site
  new(:each_site, proc {|sites| sites.primaries })
end

.host(*hostnames) ⇒ Object


25
26
27
# File 'lib/moku/sites/scope.rb', line 25

def self.host(*hostnames)
  new("host:#{hostnames}", proc {|sites| sites.host(*hostnames) })
end

.onceObject


17
18
19
# File 'lib/moku/sites/scope.rb', line 17

def self.once
  new(:once, proc {|sites| [sites.primary] })
end

.site(*site_names) ⇒ Object


21
22
23
# File 'lib/moku/sites/scope.rb', line 21

def self.site(*site_names)
  new("site:#{site_names}", proc {|sites| sites.site(*site_names).hosts })
end

Instance Method Details

#apply(sites) ⇒ Object


36
37
38
# File 'lib/moku/sites/scope.rb', line 36

def apply(sites)
  callable.call(sites)
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)

40
41
42
# File 'lib/moku/sites/scope.rb', line 40

def eql?(other)
  identifier == other.identifier
end