Class: Roast::Resources::BaseResource
- Inherits:
-
Object
- Object
- Roast::Resources::BaseResource
- Defined in:
- lib/roast/resources/base_resource.rb
Overview
Base class for all resource types Follows the Strategy pattern to handle different resource types in a polymorphic way
Direct Known Subclasses
ApiResource, DirectoryResource, FileResource, NoneResource, UrlResource
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#contents ⇒ String
Get the contents of the resource.
-
#exists? ⇒ Boolean
Check if the resource exists.
-
#initialize(target) ⇒ BaseResource
constructor
Initialize a resource with a target.
-
#name ⇒ String
Get a name for the resource to display in logs.
-
#process ⇒ String
Process the resource to prepare it for use.
-
#type ⇒ Symbol
Get the type of this resource as a symbol.
Constructor Details
#initialize(target) ⇒ BaseResource
Initialize a resource with a target
12 13 14 |
# File 'lib/roast/resources/base_resource.rb', line 12 def initialize(target) @target = target end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
8 9 10 |
# File 'lib/roast/resources/base_resource.rb', line 8 def target @target end |
Instance Method Details
#contents ⇒ String
Get the contents of the resource
30 31 32 |
# File 'lib/roast/resources/base_resource.rb', line 30 def contents nil # Override in subclasses end |
#exists? ⇒ Boolean
Check if the resource exists
24 25 26 |
# File 'lib/roast/resources/base_resource.rb', line 24 def exists? false # Override in subclasses end |
#name ⇒ String
Get a name for the resource to display in logs
36 37 38 |
# File 'lib/roast/resources/base_resource.rb', line 36 def name target || "Unnamed Resource" end |
#process ⇒ String
Process the resource to prepare it for use
18 19 20 |
# File 'lib/roast/resources/base_resource.rb', line 18 def process target end |
#type ⇒ Symbol
Get the type of this resource as a symbol
42 43 44 |
# File 'lib/roast/resources/base_resource.rb', line 42 def type :unknown end |