frenetic 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -123,7 +123,7 @@ Or install it yourself as:
123
123
 
124
124
  ```ruby
125
125
  MyAPI = Frenetic.new(
126
- # 'adapter' => :net_http # Or some other Faraday-compatible Adapter. Defaults to `:patron`
126
+ # 'adapter' => :patron # Or some other Faraday-compatible Adapter. Defaults to `:net_http`
127
127
  'url' => 'https://api.yoursite.com',
128
128
  'username' => 'yourname',
129
129
  'password' => 'yourpassword',
@@ -19,6 +19,13 @@ class Frenetic
19
19
  @_links
20
20
  end
21
21
 
22
+ def attributes
23
+ self.class.schema.keys.each_with_object({}) do |key, attrs|
24
+ attrs[key] = public_send key
25
+ end
26
+ end
27
+ alias_method :to_hash, :attributes
28
+
22
29
  # Attempts to retrieve the Resource Schema from the API based on the name
23
30
  # of the subclass.
24
31
  class << self
@@ -1,3 +1,3 @@
1
1
  class Frenetic
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
@@ -9,7 +9,7 @@ describe Frenetic::Resource do
9
9
  let(:description_stub) do
10
10
  Frenetic::HalJson::ResponseWrapper.new('resources' => {
11
11
  'schema' => {
12
- 'my_resource' => { 'properties' => { 'foo' => 'string' } },
12
+ 'my_resource' => { 'properties' => { 'foo' => 'string', 'baz' => 'integer' } },
13
13
  'my_other_resource' => { 'properties' => { 'bar' => 'integer' } }
14
14
  } } )
15
15
  end
@@ -25,6 +25,19 @@ describe Frenetic::Resource do
25
25
 
26
26
  subject { resource }
27
27
 
28
+ describe '#attributes' do
29
+ subject { resource.attributes }
30
+
31
+ it { should include 'foo' => nil }
32
+ it { should include 'baz' => nil }
33
+ end
34
+
35
+ describe '#to_hash' do
36
+ subject { resource.to_hash }
37
+
38
+ it { should == resource.attributes }
39
+ end
40
+
28
41
  context "created from a Hash" do
29
42
  let(:resource) { MyResource.new( foo: 'bar' ) }
30
43
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frenetic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: