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.



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

def initialize
  super
  set_defaults
end

Instance Method Details

#log_file=(path) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/rpush/configuration.rb', line 61

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

#logger=(logger) ⇒ Object



69
70
71
# File 'lib/rpush/configuration.rb', line 69

def logger=(logger)
  super(logger)
end

#pid_file=(path) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/rpush/configuration.rb', line 53

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

#set_defaultsObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rpush/configuration.rb', line 73

def set_defaults
  self.push_poll = 2
  self.feedback_poll = 60
  self.batch_size = 100
  self.client = :active_record
  self.logger = nil
  self.log_file = 'log/rpush.log'
  self.pid_file = 'tmp/rpush.pid'
  self.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::INFO

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

#update(other) ⇒ Object



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

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