rails_agnostic_models 0.0.2 → 0.0.3alpha

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.
@@ -1,8 +1,34 @@
1
1
  module RailsAgnosticModels
2
- include RailsVersionHelpers
3
2
  module ActiveRecordExtensions
4
3
  module ClassMethods
5
-
4
+ def rails_2?
5
+ (defined? Rails) && (Rails::VERSION::MAJOR == 2)
6
+ end
7
+
8
+ def rails_3?
9
+ (defined? Rails) && (Rails::VERSION::MAJOR == 3)
10
+ end
11
+
12
+ def rails_4?
13
+ (defined? Rails) && (Rails::VERSION::MAJOR == 4)
14
+ end
15
+
16
+ # Takes a block that will only be executed in a Rails 2 Project
17
+ def rails_2(&block)
18
+ return nil unless rails_2?
19
+ yield
20
+ end
21
+
22
+ def rails_3(&block)
23
+ return nil unless rails_3?
24
+ yield
25
+ end
26
+
27
+ def rails_4(&block)
28
+ return nil unless rails_4?
29
+ yield
30
+ end
31
+
6
32
  def version_agnostic_scope(*args)
7
33
  if rails_2?
8
34
  named_scope(*args)
@@ -19,7 +45,6 @@ module RailsAgnosticModels
19
45
  end
20
46
  end
21
47
  end
22
-
23
48
  def self.included(klass)
24
49
  klass.extend(ClassMethods)
25
50
  end
@@ -1,8 +1,5 @@
1
1
  module RailsAgnosticModels
2
2
  module RailsVersionHelpers
3
- def self.included(klass)
4
- klass.extend(ClassMethods)
5
- end
6
3
  module ClassMethods
7
4
  def rails_2?
8
5
  (defined? Rails) && (Rails::VERSION::MAJOR == 2)
@@ -32,5 +29,8 @@ module RailsAgnosticModels
32
29
  yield
33
30
  end
34
31
  end
32
+ sdef self.included(klass)
33
+ klass.extend(ClassMethods)
34
+ end
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAgnosticModels
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3alpha"
3
3
  end
@@ -1,4 +1,3 @@
1
1
  require "rails_agnostic_models/version"
2
2
  require "active_record"
3
- require 'rails_agnostic_models/rails_version_helpers'
4
3
  require "rails_agnostic_models/active_record_extensions"
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_agnostic_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3alpha
5
+ prerelease: 5
6
6
  platform: ruby
7
7
  authors:
8
8
  - DVG
@@ -92,16 +92,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  segments:
94
94
  - 0
95
- hash: 3379864087474982938
95
+ hash: -4167244641327092114
96
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
- - - ! '>='
99
+ - - ! '>'
100
100
  - !ruby/object:Gem::Version
101
- version: '0'
102
- segments:
103
- - 0
104
- hash: 3379864087474982938
101
+ version: 1.3.1
105
102
  requirements: []
106
103
  rubyforge_project:
107
104
  rubygems_version: 1.8.24