created bidsketch_objects, refactored client

Dylan Montgomery committed Jun 03, 2015
commit 5dde34e100d7bbba1f41bb72880868e657b92897
Showing 3 changed files with 10 additions and 3 deletions
bidsketch.rb b/lib/bidsketch.rb +1 -0
@@ @@ -1,5 +1,6 @@
require "bidsketch/version"
require "bidsketch/api"
+ require "bidsketch/bidsketch_object"
require "bidsketch/client"
module Bidsketch
bidsketch/bidsketch_object.rb b/lib/bidsketch/bidsketch_object.rb +6 -0
@@ @@ -0,0 +1,6 @@
+ require 'ostruct'
+
+ module Bidsketch
+ class BidsketchObject < OpenStruct
+ end
+ end
\ No newline at end of file
bidsketch/client.rb b/lib/bidsketch/client.rb +3 -3
@@ @@ -1,14 +1,14 @@
module Bidsketch
- class Client
+ class Client < BidsketchObject
class << self
def all
- Bidsketch::API.get('/clients.json').map { |client| OpenStruct.new(client) }
+ Bidsketch::API.get('/clients.json').map { |client| self.new(client) }
end
def find(id)
response = Bidsketch::API.get("/clients/#{id}.json")
if response
- OpenStruct.new(response)
+ self.new(response)
end
end
end