Skip to content

Commit

Permalink
Merge pull request #1 from dobtco/rails-5
Browse files Browse the repository at this point in the history
add rails 5 support
  • Loading branch information
ajb committed Jul 5, 2016
2 parents 00b9259 + c581fd4 commit 4627bc5
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
@@ -1 +1 @@
2.3.0
2.3.1
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -3,3 +3,6 @@ cache: bundler
script: bundle exec rspec
notifications:
email: false
gemfile:
- gemfiles/rails_5.gemfile
- gemfiles/rails_4.gemfile
7 changes: 7 additions & 0 deletions Appraisals
@@ -0,0 +1,7 @@
appraise 'rails_5' do
gem 'rails', '5.0.0'
end

appraise 'rails_4' do
gem 'rails', '4.2.6'
end
7 changes: 7 additions & 0 deletions gemfiles/rails_4.gemfile
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "4.2.6"

gemspec :path => "../"
7 changes: 7 additions & 0 deletions gemfiles/rails_5.gemfile
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "5.0.0"

gemspec :path => "../"
18 changes: 5 additions & 13 deletions lib/storage_unit/core.rb
Expand Up @@ -3,30 +3,22 @@ module Core
extend ActiveSupport::Concern

included do
default_scope { where(with_deleted_scope_sql) }
default_scope { where(default_scope_hash) }
define_model_callbacks :trash
define_model_callbacks :recover
end

module ClassMethods
def with_deleted_scope_sql
all.table[storage_unit_opts[:column]].eq(nil).to_sql
def default_scope_hash
{ storage_unit_opts[:column] => nil }
end

def deleted_only_scope_sql
all.table[storage_unit_opts[:column]].not_eq(nil).to_sql
end

# lifted from acts_as_paranoid, works around https://github.com/rails/rails/issues/4306
# with this in place Post.limit(10).with_deleted, will work as expected
def with_deleted
scope = self.all
scope.where_values.delete(with_deleted_scope_sql)
scope
self.all.unscope(where: storage_unit_opts[:column])
end

def deleted_only
with_deleted.where(deleted_only_scope_sql)
with_deleted.where.not(default_scope_hash)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/storage_unit/version.rb
@@ -1,3 +1,3 @@
module StorageUnit
VERSION = '0.1.0'
VERSION = '0.2.0'
end
3 changes: 2 additions & 1 deletion storage_unit.gemspec
Expand Up @@ -19,8 +19,9 @@ Gem::Specification.new do |s|

s.homepage = 'http://github.com/dobtco/storage_unit'

s.add_dependency 'rails', '~> 4.1', '>= 4.1.0'
s.add_dependency 'rails', '>= 4.1.0'

s.add_development_dependency 'appraisal'
s.add_development_dependency 'coveralls'
s.add_development_dependency 'guard-rspec'
s.add_development_dependency 'rspec-rails'
Expand Down

0 comments on commit 4627bc5

Please sign in to comment.