short_circuit 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82ba9bf7e740eb2c2d50b767e63025893c51c11f
4
- data.tar.gz: 75510a972b29489923a5fbe7b25285afd57dce0b
3
+ metadata.gz: d93e00b341cbd357c7c7a62d8557d44fdd7df9e3
4
+ data.tar.gz: 0b2407c1a4bf746bbcc315ce191fe9370779f3d2
5
5
  SHA512:
6
- metadata.gz: 172e84d9ae5b7c5c8965061ab49048e2a16f8266cf65cf38daee8e74d1e045867112b30b2b6242f2192fdcb4473b0b95c615dbe4bf74f3f0ea2f58a0e58a90dc
7
- data.tar.gz: 48fba1a87f641240f4e8aafb6b07d42d2a01694252b6f3d13b25c5d48010020a526072696f4ba8d0b6fd853a7fc2eb2dce7e39fb7c9510d7c03b64d365e48124
6
+ metadata.gz: ef89a8b63fbaae886ecea3bdf9f2d4145a346435876d447acc716be6b2d821738955a1b7ce00f3b816f9f56d8bde42e6bd728d49c70eb8ff4e7054ae22713aea
7
+ data.tar.gz: fceb9078d1575cc3182a62e51bed2e0949b6127beb46f50bb75448fc60269ea0346c9de13f36cebde4ca4324c2f8fc687a45aab1a15b606def300b33d0e5bd44
data/README.md CHANGED
@@ -102,11 +102,10 @@ In the view, you don't need to instantiate any presenter/decorator objects, just
102
102
  @user.present! :not_a_real_method # NoMethodError
103
103
  ```
104
104
 
105
- Design goals for short_circuit
106
- ===============================
105
+ Design goals
106
+ ============
107
107
  * Minimize project size and scope
108
108
  * Preserve direct access to model attributes
109
109
  * Create a separate access point for presenter methods
110
- * Integrate with ActiveRecord models by default
111
110
  * Silence accessor errors by default
112
111
  * Delegate missing presenter methods to the model object
@@ -1,6 +1,6 @@
1
1
  module ShortCircuit
2
2
  require 'active_support/all'
3
-
3
+
4
4
  require 'short_circuit/version'
5
5
  require 'short_circuit/presenter'
6
6
  require 'short_circuit/presentable'
@@ -5,11 +5,9 @@ module ShortCircuit
5
5
  end
6
6
 
7
7
  def present(method, *args, &block)
8
- begin
9
- present!(method, *args, &block)
10
- rescue Exception => error
11
- presenter.error_response(error, method, *args, &block)
12
- end
8
+ present!(method, *args, &block)
9
+ rescue Exception => error
10
+ presenter.error_response(error, method, *args, &block)
13
11
  end
14
12
 
15
13
  def present!(method, *args, &block)
@@ -21,7 +19,7 @@ module ShortCircuit
21
19
  def find_presenter
22
20
  presenter_class_name = "#{self.class.name}Presenter"
23
21
  presenter_class = Object.const_get(presenter_class_name)
24
-
22
+
25
23
  presenter_class.new(self)
26
24
  end
27
25
  end
@@ -5,7 +5,9 @@ module ShortCircuit
5
5
  delegate :url_helpers, to: 'Rails.application.routes'
6
6
 
7
7
  def initialize(presentable_object)
8
- instance_variable_set("@#{presentable_object.class.to_s.underscore}", presentable_object)
8
+ instance_variable_set(
9
+ "@#{presentable_object.class.to_s.underscore}",
10
+ presentable_object)
9
11
 
10
12
  super(presentable_object)
11
13
  end
@@ -13,7 +15,7 @@ module ShortCircuit
13
15
  def error_response(error, method, *args, &block)
14
16
  ''
15
17
  end
16
-
18
+
17
19
  private
18
20
 
19
21
  def controller_helpers
@@ -22,13 +24,12 @@ module ShortCircuit
22
24
 
23
25
  def method_missing(method, *args, &block)
24
26
  if controller_helpers.respond_to?(method)
25
- controller_helpers.send(method, *args, &block)
27
+ controller_helpers.send(method, *args, &block)
26
28
  elsif url_helpers.respond_to?(method)
27
29
  url_helpers.send(method, *args, &block)
28
30
  else
29
31
  super(method, *args, &block)
30
- end
32
+ end
31
33
  end
32
-
33
34
  end
34
35
  end
@@ -1,3 +1,3 @@
1
1
  module ShortCircuit
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -34,7 +34,7 @@ module ShortCircuit
34
34
  let(:method) { :fake_method }
35
35
 
36
36
  it 'does not throw an error' do
37
- expect{model.present(method)}.to_not raise_error
37
+ expect { model.present(method) }.to_not raise_error
38
38
  end
39
39
 
40
40
  it 'calls the error_response method' do
@@ -58,7 +58,7 @@ module ShortCircuit
58
58
  let(:method) { :fake_method }
59
59
 
60
60
  it 'throws an error' do
61
- expect{model.present!(method)}.to raise_error(NoMethodError)
61
+ expect { model.present!(method) }.to raise_error
62
62
  end
63
63
  end
64
64
  end
@@ -2,7 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  module ShortCircuit
4
4
  describe Presenter do
5
- let(:presentable_object) { mock_model('TestModel', test_method: 'Test Method') }
5
+ let(:presentable_object) do
6
+ mock_model('TestModel', test_method: 'Test Method')
7
+ end
6
8
 
7
9
  let(:presenter) { Presenter.new(presentable_object) }
8
10
 
@@ -29,7 +31,8 @@ module ShortCircuit
29
31
  end
30
32
 
31
33
  it 'set an instance variable for presentable_object' do
32
- expect(presenter.instance_variable_get("@#{presentable_object.class.to_s.underscore}")).to eq(presentable_object)
34
+ var = "@#{presentable_object.class.to_s.underscore}"
35
+ expect(presenter.instance_variable_get(var)).to eq(presentable_object)
33
36
  end
34
37
  end
35
38
 
@@ -49,6 +52,5 @@ module ShortCircuit
49
52
  expect(error_response).to be_empty
50
53
  end
51
54
  end
52
-
53
55
  end
54
56
  end
@@ -1,3 +1,6 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
1
4
  ENV['RAILS_ENV'] ||= 'test'
2
5
 
3
6
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: short_circuit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Pruetting