Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Migrate BitmaskAttributes to HasBitmaskattributes

  • Loading branch information...
commit 778d5451295be97aa4ec0d58b40258fd32c61393 1 parent cc1e7a2
@amiel authored
View
3  init.rb
@@ -1 +1,2 @@
-ActiveRecord::Base.send :extend, BitmaskAttributes
+# TODO: Use the real rails 3 stuff
+ActiveRecord::Base.send :extend, HasBitmaskAttributes
View
20 lib/bitmask_attributes.rb
@@ -1,20 +0,0 @@
-require 'bitmask_attribute_generator'
-
-
-module BitmaskAttributes
-
- 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
View
22 lib/has_bitmask_attributes.rb
@@ -1,5 +1,21 @@
-require "has_bitmask_attributes/version"
+
+require_relative 'bitmask_attribute_generator'
+
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
View
4 test/bitmask_attributes_test.rb
@@ -4,14 +4,14 @@
require 'active_record'
require_relative '../lib/bitmask'
-require_relative '../lib/bitmask_attributes'
+require_relative '../lib/has_bitmask_attributes'
require_relative '../lib/bitmask_attribute_generator'
class MockModel
attr_accessor :dummy_mask
attr_accessor :another_dummy_mask
- extend ::BitmaskAttributes
+ extend ::HasBitmaskAttributes
def write_attribute(sym, value)
send "#{sym}=", value
Please sign in to comment.
Something went wrong with that request. Please try again.