extended_has_enumeration 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/has_enumeration.rb +25 -0
  2. metadata +53 -0
@@ -0,0 +1,25 @@
1
+ require 'active_record'
2
+
3
+ # Install our common ActiveRecord extentions
4
+ require 'has_enumeration/class_methods'
5
+ ActiveRecord::Base.extend(HasEnumeration::ClassMethods)
6
+
7
+ # We have two primary use cases, versions of ActiveRecord which define the column mapping in Arel,
8
+ # and those which do not. For ActiveRecord 2.x.x and versions ActiveRecord which rely on
9
+ # versions of Arel > 3.0.0, we have column mapping directly in ActiveRecord.
10
+ # For the remaining cases, the method of determining column mappings is similar but not identical.
11
+ # In general, Arel 2.x.x needs the mapping code described in HasEnumeration::Arel::TableExtensions,
12
+ # whereas older versions of Arel need the code in HasEnumeration::Arel::TableExtensionsArelOne.
13
+ if ActiveRecord::VERSION::MAJOR >= 3
14
+ if Arel::VERSION >= "3.0.0"
15
+ require 'has_enumeration/aggregate_conditions_override'
16
+ elsif Arel::VERSION >= '2.0.0'
17
+ require 'has_enumeration/arel/table_extensions'
18
+ Arel::Table.send(:include, HasEnumeration::Arel::TableExtensions)
19
+ else
20
+ require 'has_enumeration/arel/table_extensions_arel_one'
21
+ Arel::Table.send(:include, HasEnumeration::Arel::TableExtensionsArelOne)
22
+ end
23
+ else
24
+ require 'has_enumeration/aggregate_conditions_override'
25
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: extended_has_enumeration
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Evan Dowling
9
+ - Maxim Tsaplin
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-06-16 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: Extends ActiveRecord with the has_enumeration method allowing a symbolic
16
+ enumeration to be stored in an ActiveRecord attribute. The enumeration is specified
17
+ as a mapping between symbols and their underlying representation in the database.
18
+ Predicates are provided for each symbol in the enumeration and the symbols may be
19
+ used in finder methods. When using ActiveRecord 3, the symbols may also be used
20
+ when interacting with the underlying Arel attribute for the enumeration. has_enumeration
21
+ has been tested with Ruby 1.8.7, Ruby 1.9.2, JRuby 1.5.5, Rubinius 1.1.0, ActiveRecord
22
+ 2.3.10, and ActiveRecord 3.0.3.
23
+ email: maxtsap@gamil.com
24
+ executables: []
25
+ extensions: []
26
+ extra_rdoc_files: []
27
+ files:
28
+ - lib/has_enumeration.rb
29
+ homepage: http://rubygems.org/gems/extended_has_enumeration
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.25
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: Extended has_enumeration
53
+ test_files: []