lib/kentaa/api/resources/resource.rb in kentaa-api-0.3.2 vs lib/kentaa/api/resources/resource.rb in kentaa-api-0.4.0

- old
+ new

@@ -24,15 +24,46 @@ @id = data.fetch(:id) if data.key?(:id) self end + def save(attributes) + if id + @response = update_resource(attributes) + else + @response = create_resource(attributes) + @id = data.fetch(:id) if data.key?(:id) + end + + self + end + + def delete + delete_resource + + self + end + def created_at Time.parse(data[:created_at]) if data[:created_at] end def updated_at Time.parse(data[:updated_at]) if data[:updated_at] + end + + private + + def create_resource + raise NotImplementedError + end + + def update_resource + raise NotImplementedError + end + + def delete_resource + raise NotImplementedError end end end end end