Permalink
Browse files

Merge pull request #27 from underlog/master

Fix for active record integration (issue #3)
  • Loading branch information...
2 parents 3fb4d5a + 9d351e5 commit 16e8d66fbfcb46db9ac4f7aa9d39a8c4ddce3e65 @turadg turadg committed Aug 22, 2011
Showing with 4 additions and 4 deletions.
  1. +1 −1 README.rdoc
  2. +3 −3 lib/enumerated_attribute/method_definition_dsl.rb
View
@@ -568,7 +568,7 @@ To test the plugin for regular ruby objects, run:
Testing ActiveRecord integration requires the install of Sqlite3 and the
sqlite3-ruby gem. To test ActiveRecord, run:
- rake spec:active_record
+ rake spec:ar
And for testing +enum_select+ in form views:
@@ -124,7 +124,7 @@ def create_custom_method_for_symbol_or_string(mdef)
if (!@attr_descriptor.empty? && !@attr_descriptor.include?(mdef.argument.to_sym))
raise(InvalidDefinition, "'#{mdef.argument}' in method '#{mdef.method_name}' is not an enumeration value for :#{@attr_name} attribute", caller)
end
- @class_obj.class_eval("def #{mdef.method_name}; @#{@attr_name} #{mdef.negated ? '!=' : '=='} :#{mdef.argument}; end")
+ @class_obj.class_eval("def #{mdef.method_name}; self.#{@attr_name} #{mdef.negated ? '!=' : '=='} :#{mdef.argument}; end")
end
def create_custom_method_for_array_of_enums(mdef)
@@ -135,8 +135,8 @@ def create_custom_method_for_array_of_enums(mdef)
end
end
end
- @class_obj.class_eval("def #{mdef.method_name}; #{mdef.negated ? '!' : ''}[:#{mdef.argument.join(',:')}].include?(@#{@attr_name}); end")
+ @class_obj.class_eval("def #{mdef.method_name}; #{mdef.negated ? '!' : ''}[:#{mdef.argument.join(',:')}].include?(self.#{@attr_name}); end")
end
end
-end
+end

0 comments on commit 16e8d66

Please sign in to comment.