happyfunjuice 0.0.1.beta.1 → 0.0.1.beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,8 @@ class Happyfunjuice::HappyfunjuiceController < ApplicationController
2
2
 
3
3
  before_filter :verify_key
4
4
 
5
+ before_filter :select_handled_exceptions
6
+
5
7
  def activities
6
8
 
7
9
  begin
@@ -16,7 +18,7 @@ class Happyfunjuice::HappyfunjuiceController < ApplicationController
16
18
  )
17
19
  }.merge({:status=>'200'})
18
20
 
19
- rescue StandardError => e
21
+ rescue *@handled_exceptions => e
20
22
  render :json=>{:status=>'500', :error=>e.message}
21
23
  end
22
24
 
@@ -32,7 +34,7 @@ class Happyfunjuice::HappyfunjuiceController < ApplicationController
32
34
  )
33
35
  }.merge({:status=>'200'})
34
36
 
35
- rescue StandardError => e
37
+ rescue *@handled_exceptions => e
36
38
  render :json=>{:status=>'500', :error=>e.message}
37
39
  end
38
40
 
@@ -40,6 +42,14 @@ class Happyfunjuice::HappyfunjuiceController < ApplicationController
40
42
 
41
43
 
42
44
  private
45
+
46
+ def select_handled_exceptions
47
+ if Happyfunjuice.exceptions_are_fatal
48
+ @handled_exceptions = []
49
+ else
50
+ @handled_exceptions = [StandardError]
51
+ end
52
+ end
43
53
 
44
54
  def verify_key
45
55
  unless (Happyfunjuice.api_key == params[:api_key] )
@@ -3,6 +3,11 @@ Happyfunjuice.setup do |config|
3
3
  # Insert the API key from the HappyFunJuice settings page here:
4
4
  config.api_key = "<%=@api_key%>"
5
5
 
6
+ # By default, exceptions encountered while querying activities are passed
7
+ # back as an error message. Debugging is much easier though if exceptions
8
+ # cause an application error.
9
+ # config.exceptions_are_fatal = false
10
+
6
11
  # Sample usage:
7
12
  #
8
13
  # config.activity :new_user, User do |u|
@@ -29,8 +29,8 @@ module Happyfunjuice
29
29
  Happyfunjuice.environment = env.to_s
30
30
  end
31
31
 
32
- def debug_mode= bool
33
- Happyfunjuice.debug_mode = !!(bool)
32
+ def exceptions_are_fatal= bool
33
+ Happyfunjuice.exceptions_are_fatal = !!(bool)
34
34
  end
35
35
 
36
36
  def activity( key, scope, opts={}, &block )
@@ -1,5 +1,5 @@
1
1
  module Happyfunjuice
2
- VERSION = "0.0.1.beta.1"
2
+ VERSION = "0.0.1.beta.2"
3
3
 
4
4
  class << self
5
5
  def version
data/lib/happyfunjuice.rb CHANGED
@@ -10,7 +10,7 @@ module Happyfunjuice
10
10
 
11
11
  # Variables for Juice
12
12
  @@apikey = nil
13
- @@debug_mode = false
13
+ @@exceptions_are_fatal = false
14
14
  @@environment = 'production'
15
15
 
16
16
  # Variables for landing page:
@@ -19,7 +19,7 @@ module Happyfunjuice
19
19
  @@mailer_api_key = 'api-key'
20
20
  @@newsletter_list = 'newsletters'
21
21
 
22
- mattr_accessor :api_key, :debug_mode
22
+ mattr_accessor :api_key, :exceptions_are_fatal
23
23
  mattr_accessor :mailer, :mailer_api_user, :mailer_api_key, :newsletter_list
24
24
  mattr_accessor :environment
25
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happyfunjuice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta.1
4
+ version: 0.0.1.beta.2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: