Class: Gush::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/gush/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Configuration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
# File 'lib/gush/configuration.rb', line 11

def initialize(hash = {})
  self.concurrency = hash.fetch(:concurrency, 5)
  self.namespace   = hash.fetch(:namespace, 'gush')
  self.redis_url   = hash.fetch(:redis_url, 'redis://localhost:6379')
  self.gushfile    = hash.fetch(:gushfile, 'Gushfile.rb')
  self.environment = hash.fetch(:environment, 'development')
end

Instance Attribute Details

#concurrencyObject

Returns the value of attribute concurrency.



5
6
7
# File 'lib/gush/configuration.rb', line 5

def concurrency
  @concurrency
end

#environmentObject

Returns the value of attribute environment.



5
6
7
# File 'lib/gush/configuration.rb', line 5

def environment
  @environment
end

#namespaceObject

Returns the value of attribute namespace.



5
6
7
# File 'lib/gush/configuration.rb', line 5

def namespace
  @namespace
end

#redis_urlObject

Returns the value of attribute redis_url.



5
6
7
# File 'lib/gush/configuration.rb', line 5

def redis_url
  @redis_url
end

Class Method Details

.from_json(json) ⇒ Object



7
8
9
# File 'lib/gush/configuration.rb', line 7

def self.from_json(json)
  new(Gush::JSON.decode(json, symbolize_keys: true))
end

Instance Method Details

#gushfileObject



23
24
25
# File 'lib/gush/configuration.rb', line 23

def gushfile
  @gushfile.realpath
end

#gushfile=(path) ⇒ Object



19
20
21
# File 'lib/gush/configuration.rb', line 19

def gushfile=(path)
  @gushfile = Pathname(path)
end

#to_hashObject



27
28
29
30
31
32
33
34
# File 'lib/gush/configuration.rb', line 27

def to_hash
  {
    concurrency: concurrency,
    namespace:   namespace,
    redis_url:   redis_url,
    environment: environment
  }
end

#to_jsonObject



36
37
38
# File 'lib/gush/configuration.rb', line 36

def to_json
  Gush::JSON.encode(to_hash)
end