Class: ActiveProject::Resources::PersistableResource

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/active_project/resources/persistable_resource.rb

Direct Known Subclasses

Comment, Issue, Project

Instance Attribute Summary

Attributes inherited from BaseResource

#adapter, #attributes, #raw_data

Instance Method Summary collapse

Methods inherited from BaseResource

def_members, #initialize, #inspect, members, #method_missing, #respond_to_missing?, #to_h

Constructor Details

This class inherits a constructor from ActiveProject::Resources::BaseResource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveProject::Resources::BaseResource

Instance Method Details

#deleteObject Also known as: destroy



22
23
24
# File 'lib/active_project/resources/persistable_resource.rb', line 22

def delete
  raise NotImplementedError, "#{self.class.name} must implement #delete"
end

#persisted?Boolean

Indicates if the resource has been persisted (typically by checking for an ID)

Returns:

  • (Boolean)


7
8
9
# File 'lib/active_project/resources/persistable_resource.rb', line 7

def persisted?
  !id.nil? # Assumes an 'id' member
end

#saveObject

These are now expected to be implemented by concrete subclasses like Issue and Comment, or this class could provide a template that calls conventionally named adapter methods.



14
15
16
# File 'lib/active_project/resources/persistable_resource.rb', line 14

def save
  raise NotImplementedError, "#{self.class.name} must implement #save"
end

#update(attributes) ⇒ Object



18
19
20
# File 'lib/active_project/resources/persistable_resource.rb', line 18

def update(attributes)
  raise NotImplementedError, "#{self.class.name} must implement #update"
end