Module: Pushr::Core
- Defined in:
- lib/pushr/core.rb
Constant Summary collapse
- NAME =
'Pushr'
- DEFAULTS =
{ external_id_tag: 'external_id' }
Instance Attribute Summary collapse
-
#options ⇒ Object
writeonly
Sets the attribute options.
Class Method Summary collapse
- .configuration_file ⇒ Object
- .configuration_file=(filename) ⇒ Object
-
.configure {|_self| ... } ⇒ Object
Configuration for Pushr, use like:.
- .external_id_tag ⇒ Object
- .external_id_tag=(value) ⇒ Object
-
.instrument(name, payload = {}) ⇒ Object
instruments with a block.
- .options ⇒ Object
- .redis(&block) ⇒ Object
- .redis=(hash) ⇒ Object
Instance Attribute Details
#options=(value) ⇒ Object (writeonly)
Sets the attribute options
16 17 18 |
# File 'lib/pushr/core.rb', line 16 def (value) @options = value end |
Class Method Details
.configuration_file ⇒ Object
57 58 59 |
# File 'lib/pushr/core.rb', line 57 def self.configuration_file [:configuration_file] end |
.configuration_file=(filename) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pushr/core.rb', line 61 def self.configuration_file=(filename) if filename filename = File.join(Dir.pwd, filename) unless Pathname.new(filename).absolute? if File.file?(filename) [:configuration_file] = filename else fail ArgumentError, "can not find config file: #{filename}" end end end |
.configure {|_self| ... } ⇒ Object
28 29 30 |
# File 'lib/pushr/core.rb', line 28 def self.configure yield self end |
.external_id_tag ⇒ Object
53 54 55 |
# File 'lib/pushr/core.rb', line 53 def self.external_id_tag [:external_id_tag] end |
.external_id_tag=(value) ⇒ Object
49 50 51 |
# File 'lib/pushr/core.rb', line 49 def self.external_id_tag=(value) [:external_id_tag] = value end |
.instrument(name, payload = {}) ⇒ Object
instruments with a block
73 74 75 76 77 |
# File 'lib/pushr/core.rb', line 73 def self.instrument(name, payload = {}) ActiveSupport::Notifications.instrument(name, payload) do yield end end |
.options ⇒ Object
18 19 20 |
# File 'lib/pushr/core.rb', line 18 def self. @options ||= DEFAULTS.dup end |
.redis(&block) ⇒ Object
32 33 34 35 36 |
# File 'lib/pushr/core.rb', line 32 def self.redis(&block) fail ArgumentError, 'requires a block' unless block @redis ||= Pushr::RedisConnection.create @redis.with(&block) end |
.redis=(hash) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pushr/core.rb', line 38 def self.redis=(hash) if hash.is_a?(Hash) .merge!(hash) @redis = RedisConnection.create() elsif hash.is_a?(ConnectionPool) @redis = hash else fail ArgumentError, 'redis= requires a Hash or ConnectionPool' end end |