lib/kentaa/api/resources/resource.rb in kentaa-api-0.2.1 vs lib/kentaa/api/resources/resource.rb in kentaa-api-0.3.0
- old
+ new
@@ -3,12 +3,21 @@
require 'time'
module Kentaa
module Api
module Resources
- module Resource
- def id
- data[:id]
+ class Resource < Base
+ attr_accessor :id
+
+ def initialize(config, options = {})
+ super(config, options)
+
+ if options.key?(:data)
+ @data = options.delete(:data) || {}
+ @id = @data.fetch(:id) if @data.key?(:id)
+ elsif options.key?(:id)
+ @id = options.delete(:id)
+ end
end
def created_at
Time.parse(data[:created_at]) if data[:created_at]
end