Permalink
Browse files

Callbacks: Added Rails 4.1+ terminator conditional

  • Loading branch information...
1 parent 44df863 commit 36a91fefab12c2bd025e50dab016390111ed41b5 @kmcbride kmcbride committed with jyurek Jan 5, 2014
Showing with 30 additions and 1 deletion.
  1. +3 −0 .travis.yml
  2. +5 −0 Appraisals
  3. +11 −0 gemfiles/4.1.gemfile
  4. +11 −1 lib/paperclip/callbacks.rb
View
@@ -17,6 +17,7 @@ gemfile:
- gemfiles/3.1.gemfile
- gemfiles/3.2.gemfile
- gemfiles/4.0.gemfile
+ - gemfiles/4.1.gemfile
matrix:
allow_failures:
@@ -26,3 +27,5 @@ matrix:
exclude:
- rvm: 1.9.2
gemfile: gemfiles/4.0.gemfile
+ - rvm: 1.9.2
+ gemfile: gemfiles/4.1.gemfile
View
@@ -17,3 +17,8 @@ appraise "4.0" do
gem "rails", "~> 4.0.0"
gem "paperclip", :path => "../"
end
+
+appraise "4.1" do
+ gem "rails", "~> 4.1.0.beta"
+ gem "paperclip", :path => "../"
+end
View
@@ -0,0 +1,11 @@
+# This file was generated by Appraisal
+
+source "https://rubygems.org"
+
+gem "jruby-openssl", :platform=>:jruby
+gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
+gem "sqlite3", :platform=>:ruby
+gem "rails", "~> 4.1.0.beta"
+gem "paperclip", :path=>"../"
+
+gemspec :path=>"../"
@@ -7,7 +7,7 @@ def self.included(base)
module Defining
def define_paperclip_callbacks(*callbacks)
- define_callbacks *[callbacks, {terminator: -> (target, result) {result == false}}].flatten
+ define_callbacks *[callbacks, {:terminator => callback_terminator}].flatten
callbacks.each do |callback|
eval <<-end_callbacks
def before_#{callback}(*args, &blk)
@@ -19,6 +19,16 @@ def after_#{callback}(*args, &blk)
end_callbacks
end
end
+
+ private
+
+ def callback_terminator
+ if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new('4.1.0.beta')
+ lambda { |target, result| result == false }
+ else
+ 'result == false'
+ end
+ end
end
module Running

0 comments on commit 36a91fe

Please sign in to comment.