booleanize 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 0.5.0 (03 Sep 2010)
2
+ * Ok, we're now compatible with both Rails 2 and 3. Be it scope or
3
+ named_scope, they will be created.
4
+
1
5
  0.4.0 (03 Sep 2010)
2
6
  * Updated to use Rspec2 (now to run the tests just do `rspec ./spec`)
3
7
  * Changed the scope creation to use "scope" instead of "named_scope" so we no
@@ -94,6 +94,10 @@ You can simply write
94
94
  Just clone the plugin inside <tt>RAILS_ROOT/vendor/plugins</tt>
95
95
 
96
96
  git clone git://github.com/cassiomarques/booleanize.git
97
+
98
+ === Rails 3
99
+
100
+ The 0.4 version and above are suited for use with Rails 3 and are NOT backward compatible with version 0.3
97
101
 
98
102
  == Running the tests
99
103
 
@@ -82,13 +82,16 @@ module Booleanize
82
82
  end
83
83
 
84
84
  private
85
-
86
85
  def create_true_scope(attr_name)
87
- scope attr_name, :conditions => { attr_name => true }
86
+ create_scope [attr_name, {:conditions => {attr_name => true}}]
88
87
  end
89
88
 
90
89
  def create_false_scope(attr_name)
91
- scope :"not_#{attr_name}", :conditions => { attr_name => false }
90
+ create_scope [:"not_#{attr_name}", {:conditions => {attr_name => false}}]
91
+ end
92
+
93
+ def create_scope(params)
94
+ Rails.version > "2.3.8" ? scope(*params) : named_scope(*params)
92
95
  end
93
96
 
94
97
  def create_humanize_method(attr_name, true_str, false_str)
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'rspec'
3
3
  require 'active_record'
4
+ require 'ostruct'
4
5
  require File.dirname(__FILE__) + "/../lib/booleanize"
5
6
 
6
7
  ActiveRecord::Base.establish_connection(:adapter=>"sqlite3", :database => ":memory:")
@@ -8,6 +9,8 @@ require File.dirname(__FILE__) + "/db/create_testing_structure"
8
9
 
9
10
  CreateTestingStructure.migrate(:up)
10
11
 
12
+ Booleanize.const_set("Rails", OpenStruct.new(:version => "3.0.0"))
13
+
11
14
  class User < ActiveRecord::Base
12
15
  booleanize [:dumb, "Dumb as hell!", "No, this is a smart one!"], :active, [:smart, "Yes!", "No, very dumb"], :deleted => ["Yes, I'm gone", "No, I'm still here!"]
13
16
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: booleanize
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
9
- version: "0.4"
8
+ - 5
9
+ version: "0.5"
10
10
  platform: ruby
11
11
  authors:
12
12
  - "C\xC3\xA1ssio Marques"