Module: Zenbox
- Defined in:
- lib/zenbox.rb,
lib/zenbox/rails.rb,
lib/zenbox/sender.rb,
lib/zenbox/railtie.rb,
lib/zenbox/version.rb,
lib/zenbox/user_helper.rb,
lib/zenbox/configuration.rb
Defined Under Namespace
Modules: Rails, UserHelper Classes: Configuration, Railtie, Sender
Constant Summary collapse
- API_VERSION =
"1.0"
- LOG_PREFIX =
"** [Zenbox] "
- VERSION =
"0.0.8"
Class Attribute Summary collapse
-
.configuration ⇒ Object
The configuration object.
-
.model ⇒ Object
Names the Zenbox model we should be watching.
-
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Zenbox server.
Class Method Summary collapse
-
.configure(silent = false) {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
-
.logger ⇒ Object
Look for the Rails logger currently defined.
-
.post(email, data) ⇒ Object
Sends data to zenbox.
-
.report_response_body(response) ⇒ Object
Prints out the response body from Zenbox for debugging help.
-
.write_verbose_log(message) ⇒ Object
Writes out the given message to the #logger.
Class Attribute Details
.configuration ⇒ Object
The configuration object.
57 58 59 |
# File 'lib/zenbox.rb', line 57 def configuration @configuration ||= Configuration.new end |
.model ⇒ Object
Names the Zenbox model we should be watching. Set automatically when using zenbox_user
22 23 24 |
# File 'lib/zenbox.rb', line 22 def model @model end |
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Zenbox server. Must respond to #send_to_zenbox. See Zenbox::Sender.
18 19 20 |
# File 'lib/zenbox.rb', line 18 def sender @sender end |
Class Method Details
.configure(silent = false) {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
50 51 52 53 |
# File 'lib/zenbox.rb', line 50 def configure(silent = false) yield(configuration) self.sender = Sender.new(configuration) end |
.logger ⇒ Object
Look for the Rails logger currently defined
39 40 41 |
# File 'lib/zenbox.rb', line 39 def logger self.configuration.logger end |
.post(email, data) ⇒ Object
Sends data to zenbox
65 66 67 68 69 70 71 72 |
# File 'lib/zenbox.rb', line 65 def post(email, data) post_data = { :api_key => configuration.api_key, :email => email, :data => data.to_json } sender.send_to_zenbox(post_data) end |
.report_response_body(response) ⇒ Object
Prints out the response body from Zenbox for debugging help
29 30 31 |
# File 'lib/zenbox.rb', line 29 def report_response_body(response) write_verbose_log("Response from Zenbox: \n#{response}") end |
.write_verbose_log(message) ⇒ Object
Writes out the given message to the #logger
34 35 36 |
# File 'lib/zenbox.rb', line 34 def write_verbose_log() logger.info LOG_PREFIX + if logger end |