opium 1.1.4 → 1.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13533d8b2fcc45702678a6aedb3dbbe64ed6d491
4
- data.tar.gz: 9e1c3e23b1d6aee6bf6638c60a069178f02fb632
3
+ metadata.gz: bcecdde21391716e2fa90f3d7e69ed2ab99cec6e
4
+ data.tar.gz: b424a700e0cd350b3840ddaae829ef3b964776ab
5
5
  SHA512:
6
- metadata.gz: 97acb7e80800dc6efca574bc48de2dbabeac93127e808ca61aa3b916869cfaa78835bfe1ad813e39c1b329f776f09a4293a107f571462957a07ac749bbafd081
7
- data.tar.gz: 60d7e817319d5b7fd5c373149282f109a24fd1ed7006fdef5898453da05ce54c7c76a807c58d708c33fbe7714ce2eaaa4e5f359b94451fab2a1e4afa849ffa20
6
+ metadata.gz: 3f8768756d6016fad4a9c92065b955dee1b3382d9626a7079782cbb71ad2287653bb1e016fc1cac2ea43c221a0ed9e6126d04d88e30a70dfcb93d367cb1dccb9
7
+ data.tar.gz: e7def16e2b043a3ce5121fd65d8a08aa7f4ed94a6d45617217e5260b090fcae1f50c9bd87d9c12341bd43db2506e29a35b69b5eaf2e0c5eb08965c37c1fe8886
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.1.5
2
+ ### Resolved Issues
3
+ - #37: Callbacks no longer makes `:update` a private method.
4
+
1
5
  ## 1.1.4
2
6
  ### Resolved Issues
3
7
  - Persistable now filters out any readonly fields from the data sent on create.
@@ -15,16 +15,17 @@ module Opium
15
15
  define_model_callbacks :save, :create, :update, :destroy
16
16
 
17
17
  wrap_callbacks_around :save, :destroy, :touch, :find
18
- wrap_callbacks_around :initialize, :create, :update, private: true
18
+ wrap_callbacks_around :initialize, :_create, :_update, private: true
19
19
  end
20
20
 
21
21
  module ClassMethods
22
22
  def wrap_callbacks_around( *methods )
23
23
  options = methods.last.is_a?(::Hash) ? methods.pop : {}
24
24
  methods.each do |method|
25
+ callback_name = method.to_s.gsub(/\A_/, '').to_sym
25
26
  class_eval do
26
27
  define_method method do |*args|
27
- run_callbacks( method ) do
28
+ run_callbacks( callback_name ) do
28
29
  super( *args )
29
30
  end
30
31
  end
data/lib/opium/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Opium
2
- VERSION = "1.1.4"
2
+ VERSION = "1.1.5"
3
3
  end
@@ -7,11 +7,12 @@ describe Opium::Model::Callbacks do
7
7
  def save( o = {} ) end
8
8
  def destroy; end
9
9
  def touch; end
10
- def create; end
10
+ def _create; end
11
+ def _update; end
11
12
  def update; end
12
13
  def find( id ) end
13
14
 
14
- private :create, :update
15
+ private :_create, :_update
15
16
 
16
17
  include Opium::Model::Callbacks
17
18
  end
@@ -35,7 +36,7 @@ describe Opium::Model::Callbacks do
35
36
  subject { model.new }
36
37
 
37
38
  it 'should run callbacks' do
38
- subject.should receive(:run_callbacks).with(method)
39
+ subject.should receive(:run_callbacks).with(options[:callback_name] || method)
39
40
  subject.send(method, *options[:args])
40
41
  end
41
42
 
@@ -51,9 +52,11 @@ describe Opium::Model::Callbacks do
51
52
 
52
53
  it_should_behave_like 'its callbacks should be invoked for', :initialize, private: true
53
54
  it_should_behave_like 'its callbacks should be invoked for', :save
54
- it_should_behave_like 'its callbacks should be invoked for', :create, private: true
55
- it_should_behave_like 'its callbacks should be invoked for', :update, private: true
55
+ it_should_behave_like 'its callbacks should be invoked for', :_create, private: true, callback_name: :create
56
+ it_should_behave_like 'its callbacks should be invoked for', :_update, private: true, callback_name: :update
56
57
  it_should_behave_like 'its callbacks should be invoked for', :destroy
57
58
  it_should_behave_like 'its callbacks should be invoked for', :touch
58
59
  it_should_behave_like 'its callbacks should be invoked for', :find, args: ['abcd1234']
60
+
61
+ it { expect( model.new ).to respond_to(:update) }
59
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Bowers