Skip to content

Commit

Permalink
add Railtie
Browse files Browse the repository at this point in the history
  • Loading branch information
aklaiber committed Jun 26, 2014
1 parent 01caf74 commit 0e56881
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rgcm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require 'rgcm/request_builder'
require 'rgcm/message'
require 'rgcm/version'
require 'rgcm/railtie' if defined?(Rails)

module Rgcm

Expand Down
6 changes: 5 additions & 1 deletion lib/rgcm/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ class Config

URI = 'https://android.googleapis.com/gcm/send'.freeze

class << self
attr_writer :config
end

def self.api_key
''
@config['api_key']
end
end
end
15 changes: 15 additions & 0 deletions lib/rgcm/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Rgcm
class Railtie < Rails::Railtie

initializer 'setup rgcm' do
config_file = Rails.root.join('config', 'rgcm.yml')
if config_file.file?
Rgcm::Config.config = YAML.load(ERB.new(config_file.read).result)[Rails.env]
end
config.after_initialize do
puts "\nRgcm config not found. Create a config file at: config/rgcm.yml" unless config_file.file?
end
end

end
end

0 comments on commit 0e56881

Please sign in to comment.