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.



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

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')
  self.ttl         = hash.fetch(:ttl, -1)
end

Instance Attribute Details

#concurrencyObject

Returns the value of attribute concurrency.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def concurrency
  @concurrency
end

#namespaceObject

Returns the value of attribute namespace.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def namespace
  @namespace
end

#redis_urlObject

Returns the value of attribute redis_url.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def redis_url
  @redis_url
end

#ttlObject

Returns the value of attribute ttl.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def ttl
  @ttl
end

Class Method Details

.from_json(json) ⇒ Object



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

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

Instance Method Details

#gushfileObject



21
22
23
# File 'lib/gush/configuration.rb', line 21

def gushfile
  @gushfile.realpath if @gushfile.exist?
end

#gushfile=(path) ⇒ Object



17
18
19
# File 'lib/gush/configuration.rb', line 17

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

#to_hashObject



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

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

#to_jsonObject



34
35
36
# File 'lib/gush/configuration.rb', line 34

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