bitmask_attributes 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/lib/bitmask_attributes.rb +1 -1
- data/lib/bitmask_attributes/definition.rb +10 -0
- data/lib/bitmask_attributes/version.rb +1 -1
- data/test/bitmask_attributes_test.rb +4 -0
- metadata +5 -7
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/bitmask_attributes.rb
CHANGED
@@ -15,6 +15,7 @@ module BitmaskAttributes
|
|
15
15
|
create_convenience_class_method_on model
|
16
16
|
create_convenience_instance_methods_on model
|
17
17
|
create_scopes_on model
|
18
|
+
create_attribute_methods_on model
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
@@ -60,6 +61,15 @@ module BitmaskAttributes
|
|
60
61
|
)
|
61
62
|
end
|
62
63
|
|
64
|
+
# Returns the defined values as an Array.
|
65
|
+
def create_attribute_methods_on(model)
|
66
|
+
model.class_eval %(
|
67
|
+
def self.values_for_#{attribute} # def self.values_for_numbers
|
68
|
+
#{values} # [:one, :two, :three]
|
69
|
+
end # end
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
63
73
|
def create_convenience_class_method_on(model)
|
64
74
|
model.class_eval %(
|
65
75
|
def self.bitmask_for_#{attribute}(*values)
|
@@ -8,6 +8,10 @@ class BitmaskAttributesTest < ActiveSupport::TestCase
|
|
8
8
|
Campaign.destroy_all
|
9
9
|
end
|
10
10
|
|
11
|
+
should "return all defined values of a given bitmask attribute" do
|
12
|
+
assert_equal Campaign.values_for_medium, [:web, :print, :email, :phone]
|
13
|
+
end
|
14
|
+
|
11
15
|
should "can assign single value to bitmask" do
|
12
16
|
assert_stored Campaign.new(:medium => :web), :web
|
13
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitmask_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-08-04 00:00:00.000000000Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activerecord
|
17
|
-
requirement: &
|
16
|
+
requirement: &2153477300 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ~>
|
@@ -22,7 +21,7 @@ dependencies:
|
|
22
21
|
version: '3.0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153477300
|
26
25
|
description: Simple bitmask attribute support for ActiveRecord
|
27
26
|
email: joel@developwithstyle.com
|
28
27
|
executables: []
|
@@ -46,7 +45,6 @@ files:
|
|
46
45
|
- test/support/helpers.rb
|
47
46
|
- test/support/models.rb
|
48
47
|
- test/test_helper.rb
|
49
|
-
has_rdoc: true
|
50
48
|
homepage: http://github.com/joelmoss/bitmask_attributes
|
51
49
|
licenses: []
|
52
50
|
post_install_message:
|
@@ -67,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
65
|
version: '0'
|
68
66
|
requirements: []
|
69
67
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
68
|
+
rubygems_version: 1.8.6
|
71
69
|
signing_key:
|
72
70
|
specification_version: 3
|
73
71
|
summary: Simple bitmask attribute support for ActiveRecord
|