pjb3-has-bit-field 0.1.0 → 0.1.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -0,0 +1,49 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{has-bit-field}
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Paul Barry"]
9
+ s.date = %q{2009-07-17}
10
+ s.email = %q{mail@paulbarry.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README.md"
14
+ ]
15
+ s.files = [
16
+ ".document",
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README.md",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "has-bit-field.gemspec",
23
+ "lib/has-bit-field.rb",
24
+ "rails/init.rb",
25
+ "rails/init.rb",
26
+ "test/has-bit-field_test.rb",
27
+ "test/test_helper.rb"
28
+ ]
29
+ s.has_rdoc = true
30
+ s.homepage = %q{http://github.com/pjb3/has-bit-field}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.2}
34
+ s.summary = %q{Provides an easy way for dealing with bit fields and active record}
35
+ s.test_files = [
36
+ "test/has-bit-field_test.rb",
37
+ "test/test_helper.rb"
38
+ ]
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ else
46
+ end
47
+ else
48
+ end
49
+ end
data/lib/has-bit-field.rb CHANGED
@@ -6,9 +6,12 @@ module HasBitField
6
6
  def has_bit_field(bit_field_attribute, *args)
7
7
  args.each_with_index do |field,i|
8
8
  flag = (1 << i)
9
- define_method("#{field}?") do
9
+ define_method(field) do
10
10
  (send(bit_field_attribute) & flag) != 0
11
11
  end
12
+ define_method("#{field}?") do
13
+ send(field)
14
+ end
12
15
  define_method("#{field}=") do |v|
13
16
  if v.to_s == "true" || v.to_s == "1"
14
17
  send("#{bit_field_attribute}=", ((send(bit_field_attribute) || 0) | flag))
@@ -27,10 +27,10 @@ class HasBitFieldTest < Test::Unit::TestCase
27
27
  assert !p.reads_books?
28
28
 
29
29
  p.watches_tv = true
30
- assert p.likes_ice_cream?
31
- assert !p.plays_golf?
32
- assert p.watches_tv?
33
- assert !p.reads_books?
30
+ assert p.likes_ice_cream
31
+ assert !p.plays_golf
32
+ assert p.watches_tv
33
+ assert !p.reads_books
34
34
 
35
35
  p.watches_tv = false
36
36
  p.plays_golf = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pjb3-has-bit-field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Barry
@@ -26,13 +26,14 @@ files:
26
26
  - .document
27
27
  - .gitignore
28
28
  - LICENSE
29
+ - README.md
29
30
  - Rakefile
30
31
  - VERSION
32
+ - has-bit-field.gemspec
31
33
  - lib/has-bit-field.rb
32
34
  - rails/init.rb
33
35
  - test/has-bit-field_test.rb
34
36
  - test/test_helper.rb
35
- - README.md
36
37
  has_rdoc: true
37
38
  homepage: http://github.com/pjb3/has-bit-field
38
39
  post_install_message: