dish 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: f491f4e6dd55335d75c28db8a8cbfc68f5ef445e
4
- data.tar.gz: 56472250206b5de7862205d6074fcb3233cb1bc8
3
+ metadata.gz: 617dbc0f6b27306fc59b7b9779c60470c050c0da
4
+ data.tar.gz: fcd386da110affa4a0e381e7dc7acac6277c76b1
5
5
  SHA512:
6
- metadata.gz: c652e54b74c3d55db537774ccace1a900fc89a74bfb88f3d12d88474e8226167da3c1cd840823813e5de60c11146f46811ccacea444d0554b7048b041fb247a1
7
- data.tar.gz: fcc7e13e2b51c93012f6b0058a0f1dfd81c0f52cece0e6a7686b994b3295aac6f442d045fc06eca52bb7efbaadac1390f3f1f9d2cfc52f641691916041530316
6
+ metadata.gz: e356555d49c23b40f8c581a5f35dd3270bfab0d169a94cb0ada1a45e7872371b6a7048c5a1d9db8c8d77492bf88f650feddfa25fd5c6ea5df4e9bb2157b2417a
7
+ data.tar.gz: 0be9973a4b2a2a6c0cb7863c87ef2ab506b727c45c525a0514173b5f10d51fb02f59741fcac060edcaee3ca97788b8add3b1d3bad4cf2b11f8672a0424c169bb
data/README.md CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  Very simple conversion of hashes to plain Ruby objects.
8
8
  This is great for consuming JSON API's which is what I use it for.
9
+ Also works in [RubyMotion](http://www.rubymotion.com/).
9
10
 
10
11
  ## Installation
11
12
 
@@ -69,7 +70,7 @@ Values can automatically be coerced, for example into a custom `Dish` object or
69
70
  class Author < Dish::Plate; end
70
71
 
71
72
  class Product < Dish::Plate
72
- coerce :updated_at, -> (value) { Time.parse(value) }
73
+ coerce :updated_at, ->(value) { Time.parse(value) }
73
74
  coerce :authors, Author
74
75
  end
75
76
 
data/lib/dish/plate.rb CHANGED
@@ -24,6 +24,10 @@ module Dish
24
24
  end
25
25
  end
26
26
 
27
+ def respond_to_missing?(method, *args)
28
+ _check_for_presence(method.to_s) || super
29
+ end
30
+
27
31
  def as_hash
28
32
  @_original_hash
29
33
  end
data/lib/dish/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dish
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require "test_helper"
2
+ require "time" # for Time.parse in Ruby 1.9.3
2
3
 
3
4
  class DishTest < Test::Unit::TestCase
4
5
  def test_coercion
@@ -36,7 +37,7 @@ class DishTest < Test::Unit::TestCase
36
37
  class Author < Dish::Plate; end
37
38
 
38
39
  class Product < Dish::Plate
39
- coerce :updated_at, -> (value) { Time.parse(value) }
40
+ coerce :updated_at, ->(value) { Time.parse(value) }
40
41
  coerce :authors, Author
41
42
  end
42
43
 
data/test/dish_test.rb CHANGED
@@ -20,6 +20,12 @@ class DishTest < Test::Unit::TestCase
20
20
  assert_equal false, book.active?
21
21
  assert_nil book.other
22
22
  assert_equal false, book.other?
23
+ assert_respond_to book, :title
24
+ assert_respond_to book, :authors
25
+ refute_respond_to book, :doesnotexist
26
+ assert_nothing_raised do
27
+ m = book.method(:title)
28
+ end
23
29
  end
24
30
 
25
31
  def test_key_type_indifference
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lasse Bunk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-31 00:00:00.000000000 Z
11
+ date: 2014-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 2.2.1
88
+ rubygems_version: 2.2.2
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: Super simple conversion of hashes to plain Ruby objects