platanus 0.1.8 → 0.1.10

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 808d23686e78b40cc813e9b7a15698b6f17f25e5
4
+ data.tar.gz: 4ea56d405d74ad026958e79f1de37a6344b90670
5
+ SHA512:
6
+ metadata.gz: fd51feb6d0f0961f63aab31babdd537f263f62d96e5fd386da9173f5aed6edadbc749bd874f592f887f6fe484df8d10a3c916507dce2ea12937b4a704c810615
7
+ data.tar.gz: e24765ea9d1518dd68d198f8ba401a7d3cd54326df49487ea1cbf28fb369a6e53944b5b2a0c13d95e6277692793ad2af8ed1d3fc56a90c09b0c73a66e0aebca5
@@ -4,16 +4,11 @@
4
4
 
5
5
  module Platanus
6
6
 
7
- # When included in a model definition, this module
8
- # provides soft delete capabilities via the +remove+ method.
9
- #
10
- # This module also defines a +remove+ callback.
11
- #
12
- module Activable
7
+ module ActivableBase
8
+
13
9
  def self.included(base)
14
10
  base.define_callbacks :remove
15
11
  base.attr_protected :removed_at
16
- base.send(:default_scope, base.where(:removed_at => nil))
17
12
  base.extend ClassMethods
18
13
  end
19
14
 
@@ -42,21 +37,6 @@ module Platanus
42
37
  self.removed_at.nil?
43
38
  end
44
39
 
45
- # Clones current object and then removes it.
46
- def replace!
47
- # self.class.transaction do
48
- # clone = self.class.new
49
- # self.attributes.each do |key, value|
50
- # next if ['id','created_at','removed_at'].include? key
51
- # clone.send(:write_attribute, key, value)
52
- # end
53
- # yield
54
- # clone.save!
55
- # self.remove!
56
- # return clone
57
- # end
58
- end
59
-
60
40
  # Deactivates a single record.
61
41
  def remove!
62
42
  self.transaction do
@@ -79,13 +59,23 @@ module Platanus
79
59
  end
80
60
  end
81
61
 
62
+ # When included in a model definition, this module
63
+ # provides soft delete capabilities via the +remove+ method.
64
+ #
65
+ # This module also defines a +remove+ callback.
66
+ #
67
+ module Activable
68
+ def self.included(base)
69
+ base.send(:include, Platanus::ActivableBase)
70
+ base.send(:default_scope, base.where(:removed_at => nil))
71
+ end
72
+ end
73
+
82
74
  ## Same as Activable but defines an 'alive' scope and no default scope.
83
75
  module ActivableExplicit
84
76
  def self.included(base)
85
- base.define_callbacks :remove
86
- base.attr_protected :removed_at
77
+ base.send(:include, Platanus::ActivableBase)
87
78
  base.send(:scope, 'alive', base.where(:removed_at => nil))
88
- base.extend Platanus::Activable::ClassMethods
89
79
  end
90
80
  end
91
81
  end
@@ -69,9 +69,9 @@ module Platanus::TagSetAttr
69
69
  params = []; ex_sql = []
70
70
  Array(_opt[:none]).each do |token|
71
71
  params << "%::#{token}::%"
72
- ex_sql << "#{_name} is NULL OR #{_name} NOT LIKE ?"
72
+ ex_sql << "#{_name} NOT LIKE ?"
73
73
  end
74
- target = target.where("#{ex_sql.join(' AND ')}", *params) if params.length > 0
74
+ target = target.where("#{_name} is NULL OR (#{ex_sql.join(' AND ')})", *params) if params.length > 0
75
75
  end
76
76
 
77
77
  return target
@@ -1,3 +1,3 @@
1
1
  module Platanus
2
- VERSION = "0.1.8" # 0.2 will come with tests!
2
+ VERSION = "0.1.10" # 0.2 will come with tests!
3
3
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platanus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
5
- prerelease:
4
+ version: 0.1.10
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ignacio Baixas
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-02 00:00:00.000000000 Z
11
+ date: 2014-01-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: multi_json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.3.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.3.2
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: Platan.us utility gem
@@ -83,29 +78,27 @@ files:
83
78
  - spec/spec_helper.rb
84
79
  homepage: http://www.platan.us
85
80
  licenses: []
81
+ metadata: {}
86
82
  post_install_message:
87
83
  rdoc_options: []
88
84
  require_paths:
89
85
  - lib
90
86
  required_ruby_version: !ruby/object:Gem::Requirement
91
- none: false
92
87
  requirements:
93
- - - ! '>='
88
+ - - '>='
94
89
  - !ruby/object:Gem::Version
95
90
  version: '0'
96
91
  required_rubygems_version: !ruby/object:Gem::Requirement
97
- none: false
98
92
  requirements:
99
- - - ! '>='
93
+ - - '>='
100
94
  - !ruby/object:Gem::Version
101
95
  version: '0'
102
96
  requirements: []
103
97
  rubyforge_project:
104
- rubygems_version: 1.8.23
98
+ rubygems_version: 2.0.2
105
99
  signing_key:
106
- specification_version: 3
100
+ specification_version: 4
107
101
  summary: This gem contains various ruby classes used by Platanus in our rails proyects
108
102
  test_files:
109
103
  - spec/canned2_spec.rb
110
104
  - spec/spec_helper.rb
111
- has_rdoc: