better_struct 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: e0fc6242d89b02de6ec2d288148e4081e11f355a
4
- data.tar.gz: 9b8b1340921eb515841cb59524bffe739713ae9c
3
+ metadata.gz: 1c66dda2acf77cbc9d8335a5566a4c7ceb6b08c3
4
+ data.tar.gz: 4b89de754a58102d32eece33e3299fa4acd44db1
5
5
  SHA512:
6
- metadata.gz: 665dc045be6a41c18f80e32b510bc3c3db71307e37c132b5867d8bb7c1c140b0e2b7f3dedd7b31973be83929c0ea00ba8c904d07fbf79df1345f1f23acc97fdf
7
- data.tar.gz: fb9d7a520a729da768b644446a20c9514e12b8aa801cb8ebd8fdc2e2c86069c5e76225ff184f3f620aa5e0d9ecd58a573bd28793162c7d43b193e393f3923a14
6
+ metadata.gz: d3247b8c76980dd91b2e463c150e27555cbf4714f898fc8e40938d2b952d6e2c3896722e0a8c3d7e7fe3edc4d94931ad6c17ff35dea4db7663e5f29818d320ec
7
+ data.tar.gz: 6d601f5ce53b1c0d66ac0185fb5df718041be0abc976e19df56715888ba21a249934ad798e63307343d6f06ce31eac2293ff764a6aab4f5ab16a4f90c86cb32e
data/README.md CHANGED
@@ -32,13 +32,13 @@ BetterStruct.new(nil) == BetterStruct.new(nil).some_method # => true
32
32
  ```ruby
33
33
  better_struct = BetterStruct.new("foobar")
34
34
 
35
-
36
35
  better_struct[0..2].is_a?(BetterStruct) # => true
37
36
  better_struct[0..2] == BetterStruct.new("foo") # => true
38
37
  ```
39
38
 
40
39
  ```ruby
41
40
  better_struct = BetterStruct.new([1, 2, 3])
41
+
42
42
  result = better_struct.all? { |i| i.is_a?(BetterStruct) }
43
43
 
44
44
  result.is_a?(BetterStruct) # => true
@@ -49,7 +49,8 @@ result == BetterStruct.new(true) # => true
49
49
  #### Like OpenStruct
50
50
 
51
51
  ```ruby
52
- better_struct = BetterStruct.new({ "FooBar1" => { foo_bar2: "Hello World!" } })
52
+ some_hash = { "FooBar1" => { foo_bar2: "Hello World!" } }
53
+ better_struct = BetterStruct.new(some_hash)
53
54
 
54
55
  better_struct.foo_bar1.foo_bar2 == BetterStruct.new("Hello World!") # => true
55
56
  ```
@@ -58,9 +59,8 @@ better_struct.foo_bar1.foo_bar2 == BetterStruct.new("Hello World!") # => true
58
59
 
59
60
  ```ruby
60
61
  better_struct = BetterStruct.new("foobar")
61
- new_better_struct = better_struct.gsub("foo", "super-")
62
62
 
63
- new_better_struct.value == "super-foo" # => true
63
+ better_struct.gsub("foo", "super-").value == "super-foo" # => true
64
64
 
65
65
  ```
66
66
 
@@ -53,12 +53,8 @@ private
53
53
 
54
54
  if value.respond_to?(method_name)
55
55
  wrap(value.public_send(*args, &wrap_block_arguments(*args, &block)))
56
- elsif @defined_methods[method_name] || value.nil?
57
- wrap(@defined_methods[method_name])
58
56
  else
59
- error = NoMethodError.new "undefined method `#{ method_name }' for #{ self }", args
60
- error.set_backtrace caller(1)
61
- raise error
57
+ wrap(@defined_methods[method_name])
62
58
  end
63
59
  end
64
60
  end
@@ -1,3 +1,3 @@
1
1
  class BetterStruct
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -28,9 +28,11 @@ class BetterStructTest < Minitest::Test
28
28
  def test_block_argument_wrapping
29
29
  better_struct = BetterStruct.new([3, 2, 1])
30
30
 
31
- better_struct.each_with_index do |value, index|
32
- assert_equal value.class, BetterStruct
33
- assert_equal index.class, BetterStruct
31
+ better_struct.each_with_index do |val, i|
32
+ assert val.is_a?(BetterStruct)
33
+ assert val.value.is_a?(Integer)
34
+ assert i.is_a?(BetterStruct)
35
+ assert i.value.is_a?(Integer)
34
36
  end
35
37
  end
36
38
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeny Li