lib/githu3/resource.rb in githu3-0.0.3 vs lib/githu3/resource.rb in githu3-0.0.4
- old
+ new
@@ -1,26 +1,41 @@
module Githu3
- class Resource < Githu3::Store
+ class Resource
extend Githu3::Relations
def initialize(d, client)
@client = client
+
if d.is_a?(String)
- super(client.get(d).body)
+ @attributes = Githu3::Store.new(client.get(d).body)
else
- super(d)
+ @attributes = Githu3::Store.new(d)
end
end
+ def id
+ @attributes.id
+ end
+
def get *args
@client.get(*args)
end
- def path
+ def _path
return if url.nil?
URI.parse(url).path
+ end
+
+ def method_missing m, *args
+ val = @attributes.send(m, *args)
+ time_val = Time.parse(val) if m =~ /_at$/ rescue nil
+ time_val || val
+ end
+
+ def _attributes
+ @attributes
end
protected
def _client
\ No newline at end of file