Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Migrate BitmaskAttributes to HasBitmaskattributes
- Loading branch information
Amiel Martin
committed
Feb 25, 2012
1 parent
cc1e7a2
commit 778d545
Showing
4 changed files
with
23 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1 +1,2 @@ | |||
ActiveRecord::Base.send :extend, BitmaskAttributes | # TODO: Use the real rails 3 stuff | ||
ActiveRecord::Base.send :extend, HasBitmaskAttributes |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,5 +1,21 @@ | |||
require "has_bitmask_attributes/version" |
|
||
require_relative 'bitmask_attribute_generator' | |||
|
|||
|
|
||
module HasBitmaskAttributes | module HasBitmaskAttributes | ||
# Your code goes here... |
|
||
end | def has_bitmask_attributes(name) | ||
raise ArgumentError, "You must pass has_bitmask_attributes a block and define attributes." unless block_given? | |||
config = BitmaskAttributeGenerator.new(name, self) | |||
yield config | |||
config.generate | |||
end | |||
|
|||
def value_to_boolean(value) | |||
if defined? ::ActiveRecord::ConnectionAdapters::Column | |||
::ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value) | |||
else | |||
['1', 1, 't', 'true', true].include? value | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters