action_callback 0.1.0 → 0.2.0

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: ec0f61de4d5635712366cbce4c96cca8501f67cb
4
- data.tar.gz: 3438f5627ff92cd7d8aa337ae8d7179b0df54ecd
3
+ metadata.gz: 1408b24ae441a6364097562fbe661d421fce0a04
4
+ data.tar.gz: e84f0b9768c1b20ea2d7166aff9038bc5b4c1d91
5
5
  SHA512:
6
- metadata.gz: 93f777fe24f0dd70cf9e7f57b444b27413fa35d27873f9b287711fc1f889595707424cbcc22d2da1ba3a62680b09b0797f89d7dc01bbb720fffdf338748eeb83
7
- data.tar.gz: c1b6141eec6b59a7103e14ebee999ba8ba3c2b97ecc34364384a8ecff4ef46bcb5400531e2eb9ed30b2547cfc5db69197964974059e692aa02717270a8f03ebe
6
+ metadata.gz: 15efcc59e3cdff54ae5a7be3b694362614c8822d6de670ad954f9822c7999ef72bc15d48c286c5d541ddbcb2cc6f1ad567e091528a003152bb1f5a98a5884af0
7
+ data.tar.gz: e0e49cb0fd4731e3973c08df8cd70e468d462be351be18d99a5a1b76486db0aac51a4b795228a784bc0e99c7521497070752279431110eda10c06c7b98c34d1b
data/Gemfile CHANGED
@@ -1,7 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in callback_action.gemspec
4
3
  gemspec
5
4
 
6
- gem 'minitest-reporters', group: :test
7
- gem 'minitest-debugger', group: :test
5
+ group :test do
6
+ gem "sqlite3"
7
+ gem 'minitest-reporters'
8
+ gem 'minitest-debugger'
9
+ gem 'rails', '4.0.0'
10
+ end
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # CallbackAction
4
4
 
5
- This gem gives you ability to add callbacks like `before_action` / `before_fitler` etc to your class.
5
+ This gem gives you ability to add callbacks like `before_action` / `before_fitler` etc to your Active Record models and plain ruby classes.
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,12 +22,10 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- If you are using plain ruby:
25
+ If you are using Rails, in your Active Record models:
26
26
 
27
27
  ```ruby
28
- class Foobar
29
- extend ActionCallback
30
-
28
+ class Foobar < ActiveRecord::Base
31
29
  before_action :foobar, on: [:foo, :bar]
32
30
 
33
31
  def foo
@@ -44,11 +42,12 @@ class Foobar
44
42
  end
45
43
  ```
46
44
 
47
- If you are using Rails, you can save the `extend ActionCallback` line in active record models
48
- (but you will still need that when you are defining a plain ruby class):
45
+ If you are using plain ruby:
49
46
 
50
47
  ```ruby
51
- class Foobar < ActiveRecord::Base
48
+ class Foobar
49
+ extend ActionCallback
50
+
52
51
  before_action :foobar, on: [:foo, :bar]
53
52
 
54
53
  def foo
@@ -4,15 +4,18 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'action_callback/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "action_callback"
8
- spec.version = ActionCallback::VERSION
9
- spec.authors = ["Edmund Li"]
10
- spec.email = ["edmund.xz.lee@gmail.com"]
7
+ spec.name = "action_callback"
8
+ spec.version = ActionCallback::VERSION
9
+ spec.summary = 'Add callbacks to your ActiveRecord models or plain Ruby classes'
10
+ spec.description = "Here you can add callbacks to your models using `before_action`, `after_action`"
11
11
 
12
- spec.summary = 'Add callback to your ruby class'
13
- # spec.description = %q{TODO: Write a longer description or delete this line.}
14
- spec.homepage = "https://github.com/EdmundLeex/action_callback"
15
- spec.license = "MIT"
12
+ spec.required_ruby_version = ">= 2.0.0"
13
+
14
+ spec.license = "MIT"
15
+
16
+ spec.authors = ["Edmund Li"]
17
+ spec.email = ["edmund.xz.lee@gmail.com"]
18
+ spec.homepage = "https://github.com/EdmundLeex/action_callback"
16
19
 
17
20
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
21
  spec.bindir = "exe"
@@ -21,5 +24,5 @@ Gem::Specification.new do |spec|
21
24
 
22
25
  spec.add_development_dependency "bundler", "~> 1.12"
23
26
  spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "minitest", "~> 5.0"
27
+ spec.add_development_dependency "minitest", "~> 4.2"
25
28
  end
@@ -15,3 +15,7 @@ module ActionCallback
15
15
  end
16
16
  end
17
17
  end
18
+
19
+ if defined?(Rails)
20
+ ActiveRecord::Base.extend(ActionCallback)
21
+ end
@@ -1,3 +1,5 @@
1
+ require 'set'
2
+
1
3
  module Callback
2
4
  # The chain should have each method that has callback as key
3
5
  # and each callback points to a hash with :before, :after as key
@@ -1,5 +1,5 @@
1
1
  module ActionCallback
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
 
4
4
  def self.version
5
5
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_callback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edmund Li
@@ -44,15 +44,15 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '4.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
55
- description:
54
+ version: '4.2'
55
+ description: Here you can add callbacks to your models using `before_action`, `after_action`
56
56
  email:
57
57
  - edmund.xz.lee@gmail.com
58
58
  executables: []
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: '0'
88
+ version: 2.0.0
89
89
  required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
91
  - - ">="
@@ -93,8 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.2.2
96
+ rubygems_version: 2.6.8
97
97
  signing_key:
98
98
  specification_version: 4
99
- summary: Add callback to your ruby class
99
+ summary: Add callbacks to your ActiveRecord models or plain Ruby classes
100
100
  test_files: []