Class: Rpush::Configuration

Inherits:
Struct
  • Object
show all
Includes:
Deprecatable
Defined in:
lib/rpush/configuration.rb

Instance Method Summary collapse

Methods included from Deprecatable

included

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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

def initialize
  super
  set_defaults
end

Instance Method Details

#foreground=(bool) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/rpush/configuration.rb', line 44

def foreground=(bool)
  if Rpush.jruby?
    # The JVM does not support fork().
    super(true)
  else
    super
  end
end

#logger=(logger) ⇒ Object



40
41
42
# File 'lib/rpush/configuration.rb', line 40

def logger=(logger)
  super(logger)
end

#pid_file=(path) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/rpush/configuration.rb', line 32

def pid_file=(path)
  if path && !Pathname.new(path).absolute?
    super(File.join(Rails.root, path))
  else
    super
  end
end

#set_defaultsObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rpush/configuration.rb', line 53

def set_defaults
  if Rpush.jruby?
    # The JVM does not support fork().
    self.foreground = true
  else
    self.foreground = false
  end

  self.push_poll = 2
  self.feedback_poll = 60
  self.check_for_errors = true
  self.batch_size = 100
  self.pid_file = nil
  self.store = :active_record
  self.logger = nil
  self.batch_storage_updates = true

  # Internal options.
  self.embedded = false
  self.push = false
end

#update(other) ⇒ Object



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

def update(other)
  CONFIG_ATTRS.each do |attr|
    other_value = other.send(attr)
    send("#{attr}=", other_value) unless other_value.nil?
  end
end