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
16
17
# 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)
  self.locking_duration = hash.fetch(:locking_duration, 2) # how long you want to wait for the lock to be released, in seconds
  self.polling_interval = hash.fetch(:polling_internal, 0.3) # how long the polling interval should be, in seconds
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

#locking_durationObject

Returns the value of attribute locking_duration.



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

def locking_duration
  @locking_duration
end

#namespaceObject

Returns the value of attribute namespace.



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

def namespace
  @namespace
end

#polling_intervalObject

Returns the value of attribute polling_interval.



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

def polling_interval
  @polling_interval
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



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

def gushfile
  @gushfile.realpath if @gushfile.exist?
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
35
36
# File 'lib/gush/configuration.rb', line 27

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

#to_jsonObject



38
39
40
# File 'lib/gush/configuration.rb', line 38

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