Class: Rapns::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Deprecatable

included

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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

def initialize
  super
  set_defaults
end

Instance Attribute Details

#apns_feedback_callbackObject

Returns the value of attribute apns_feedback_callback.



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

def apns_feedback_callback
  @apns_feedback_callback
end

Instance Method Details

#foreground=(bool) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/rapns/configuration.rb', line 46

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

#logger=(logger) ⇒ Object



42
43
44
# File 'lib/rapns/configuration.rb', line 42

def logger=(logger)
  super(logger)
end

#on_apns_feedback(&block) ⇒ Object



55
56
57
# File 'lib/rapns/configuration.rb', line 55

def on_apns_feedback(&block)
  self.apns_feedback_callback = block
end

#pid_file=(path) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/rapns/configuration.rb', line 34

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

#set_defaultsObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rapns/configuration.rb', line 60

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

  self.push_poll = 2
  self.feedback_poll = 60
  self.airbrake_notify = true
  self.check_for_errors = true
  self.batch_size = 5000
  self.pid_file = nil
  self.apns_feedback_callback = nil
  self.store = :active_record
  self.logger = nil

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

#update(other) ⇒ Object



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

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