Module: BrickFTP::APIDefinition::ClassMethods
- Defined in:
- lib/brick_ftp/api_definition.rb
Instance Method Summary collapse
-
#api_component_for(name) ⇒ BrickFTP::APIComponent
Build BrickFTP::APIComponent.
-
#api_path_for(name, params = {}) ⇒ String
Build path for API endpoint.
-
#attribute(name, writable: false) ⇒ Object
Define attribute.
-
#attributes ⇒ Array
Return all attributes.
-
#endpoint(http_method, name, path_template, *query_keys) ⇒ Object
Define API endpoint.
Instance Method Details
#api_component_for(name) ⇒ BrickFTP::APIComponent
Build BrickFTP::APIComponent.
59 60 61 62 |
# File 'lib/brick_ftp/api_definition.rb', line 59 def api_component_for(name) raise BrickFTP::API::NoSuchAPI, "#{name} #{self.name}" unless endpoints.key?(name) BrickFTP::APIComponent.new(endpoints[name][:path_template], endpoints[name][:query_keys]) end |
#api_path_for(name, params = {}) ⇒ String
Build path for API endpoint.
52 53 54 |
# File 'lib/brick_ftp/api_definition.rb', line 52 def api_path_for(name, params = {}) api_component_for(name).path(params) end |
#attribute(name, writable: false) ⇒ Object
Define attribute.
34 35 36 37 38 39 40 |
# File 'lib/brick_ftp/api_definition.rb', line 34 def attribute(name, writable: false) if writable writable_attributes << name.to_sym else readonly_attributes << name.to_sym end end |
#attributes ⇒ Array
Return all attributes.
44 45 46 |
# File 'lib/brick_ftp/api_definition.rb', line 44 def attributes writable_attributes + readonly_attributes end |
#endpoint(http_method, name, path_template, *query_keys) ⇒ Object
Define API endpoint.
23 24 25 26 27 28 29 |
# File 'lib/brick_ftp/api_definition.rb', line 23 def endpoint(http_method, name, path_template, *query_keys) endpoints[name] = { http_method: http_method, path_template: path_template, query_keys: query_keys, } end |