Class: SmilyCli::Resource
- Inherits:
-
Struct
- Object
- Struct
- SmilyCli::Resource
- Defined in:
- lib/smily_cli/resource.rb
Overview
A single API v3 resource the CLI knows about by name: the command word the
user types (rentals), the HTTP path it maps to (rentals, or
booking/discount_codes), the singular label for help text, and grouping
metadata used by smily resources.
Anything not in the Registry is still reachable through smily api,
so the registry is about ergonomics and discoverability, not a hard gate.
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#description ⇒ Object
Returns the value of attribute description.
-
#group ⇒ Object
Returns the value of attribute group.
-
#path ⇒ Object
Returns the value of attribute path.
-
#readonly ⇒ Object
Returns the value of attribute readonly.
-
#singular ⇒ Object
Returns the value of attribute singular.
Instance Method Summary collapse
-
#collection_path ⇒ String
Path to the collection endpoint (e.g. "rentals").
-
#member_path(id) ⇒ String
Path to a member endpoint (e.g. "rentals/42").
-
#resource_key ⇒ String
The JSON:API top-level key used in request/response bodies for this resource.
-
#writable? ⇒ Boolean
Whether write commands (create/update/delete) apply.
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command
11 12 13 |
# File 'lib/smily_cli/resource.rb', line 11 def command @command end |
#description ⇒ Object
Returns the value of attribute description
11 12 13 |
# File 'lib/smily_cli/resource.rb', line 11 def description @description end |
#group ⇒ Object
Returns the value of attribute group
11 12 13 |
# File 'lib/smily_cli/resource.rb', line 11 def group @group end |
#path ⇒ Object
Returns the value of attribute path
11 12 13 |
# File 'lib/smily_cli/resource.rb', line 11 def path @path end |
#readonly ⇒ Object
Returns the value of attribute readonly
11 12 13 |
# File 'lib/smily_cli/resource.rb', line 11 def readonly @readonly end |
#singular ⇒ Object
Returns the value of attribute singular
11 12 13 |
# File 'lib/smily_cli/resource.rb', line 11 def singular @singular end |
Instance Method Details
#collection_path ⇒ String
Path to the collection endpoint (e.g. "rentals").
31 32 33 |
# File 'lib/smily_cli/resource.rb', line 31 def collection_path path end |
#member_path(id) ⇒ String
Path to a member endpoint (e.g. "rentals/42").
38 39 40 |
# File 'lib/smily_cli/resource.rb', line 38 def member_path(id) "#{path}/#{id}" end |
#resource_key ⇒ String
The JSON:API top-level key used in request/response bodies for this
resource. For v3 this is the pluralized resource name, i.e. the last
path segment (booking/discount_codes -> discount_codes).
20 21 22 |
# File 'lib/smily_cli/resource.rb', line 20 def resource_key path.split("/").last end |
#writable? ⇒ Boolean
Returns whether write commands (create/update/delete) apply.
25 26 27 |
# File 'lib/smily_cli/resource.rb', line 25 def writable? !readonly end |