power_enum 1.1.2 → 1.2.0

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.
data.tar.gz.sig CHANGED
Binary file
@@ -40,16 +40,60 @@ module PowerEnum::Reflection
40
40
  class EnumerationReflection < ActiveRecord::Reflection::MacroReflection
41
41
  attr_reader :counter_cache_column
42
42
 
43
+ # See ActiveRecore::Reflection::MacroReflection
43
44
  def initialize( name, options, active_record )
44
45
  super :has_enumerated, name, options, active_record
45
46
  end
46
-
47
+
48
+ # Returns the class name of the enum
47
49
  def class_name
48
50
  @class_name ||= (@options[:class_name] || @name).to_s.camelize
49
51
  end
50
-
52
+
53
+ # Returns the foreign key on the association owner's table.
51
54
  def foreign_key
52
55
  @foreign_key ||= (@options[:foreign_key] || "#{@name}_id").to_s
53
56
  end
57
+
58
+ # Returns the name of the enum table
59
+ def table_name
60
+ @table_name ||= self.class.const_get(class_name).table_name
61
+ end
62
+
63
+ # Returns the primary key of the active record model that owns the has_enumerated
64
+ # association.
65
+ def association_primary_key
66
+ active_record.primary_key
67
+ end
68
+
69
+ # Does nothing.
70
+ def check_validity!; end
71
+
72
+ # Returns nil
73
+ def source_reflection;
74
+ nil
75
+ end
76
+
77
+ # Returns nil
78
+ def type
79
+ nil
80
+ end
81
+
82
+ # In this case, returns [[]]
83
+ def conditions
84
+ [[]]
85
+ end
86
+
87
+ # Returns :belongs_to. Kind of hackish, but otherwise AREL joins logic
88
+ # gets confused.
89
+ def source_macro
90
+ :belongs_to
91
+ end
92
+
93
+ # Returns an array of this instance as the only member.
94
+ def chain
95
+ [self]
96
+ end
97
+
54
98
  end
55
99
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -40,7 +40,7 @@ cert_chain:
40
40
  amZaYUtWM2wwYTFkR2wyUVNMa2pScFFaRDFiRCtVSDdnT3F5N1piZGNzUkJM
41
41
  NEg3VTV6VQpibEtkZEg2dXhDckRTTTdLYWJrelNPVmYKLS0tLS1FTkQgQ0VS
42
42
  VElGSUNBVEUtLS0tLQo=
43
- date: 2013-02-24 00:00:00.000000000 Z
43
+ date: 2013-03-19 00:00:00.000000000 Z
44
44
  dependencies:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: rails
@@ -173,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  segments:
175
175
  - 0
176
- hash: -4143040860677823590
176
+ hash: 2397256601209882882
177
177
  required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  none: false
179
179
  requirements:
metadata.gz.sig CHANGED
Binary file