Class: Useless::Doc::DSL::API
- Inherits:
-
Object
- Object
- Useless::Doc::DSL::API
- Includes:
- Member
- Defined in:
- lib/useless/doc/dsl.rb
Instance Method Summary collapse
- #connect(path, &block) ⇒ Object
- #default_attributes ⇒ Object
- #delete(path, &block) ⇒ Object
- #description(description) ⇒ Object
- #generate ⇒ Object
- #get(path, &block) ⇒ Object
- #head(path, &block) ⇒ Object
-
#initialize(attributes = {}) ⇒ API
constructor
A new instance of API.
- #name ⇒ Object
- #patch(path, &block) ⇒ Object
- #post(path, &block) ⇒ Object
- #put(path, &block) ⇒ Object
- #resource(path, &block) ⇒ Object
- #timestamp(timestamp) ⇒ Object
- #trace(path, &block) ⇒ Object
- #url(url) ⇒ Object
Methods included from Member
Constructor Details
#initialize(attributes = {}) ⇒ API
Returns a new instance of API.
104 105 106 107 |
# File 'lib/useless/doc/dsl.rb', line 104 def initialize(attributes = {}) @resource_dsls = [] super end |
Instance Method Details
#connect(path, &block) ⇒ Object
169 170 171 |
# File 'lib/useless/doc/dsl.rb', line 169 def connect(path, &block) resource(path).connect(&block) end |
#default_attributes ⇒ Object
109 110 111 |
# File 'lib/useless/doc/dsl.rb', line 109 def default_attributes { resources: [] } end |
#delete(path, &block) ⇒ Object
161 162 163 |
# File 'lib/useless/doc/dsl.rb', line 161 def delete(path, &block) resource(path).delete(&block) end |
#description(description) ⇒ Object
129 130 131 |
# File 'lib/useless/doc/dsl.rb', line 129 def description(description) @attributes[:description] = description end |
#generate ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/useless/doc/dsl.rb', line 113 def generate @attributes[:resources] = @resource_dsls.map do |resource_dsl| resource_dsl.generate end super end |
#get(path, &block) ⇒ Object
141 142 143 |
# File 'lib/useless/doc/dsl.rb', line 141 def get(path, &block) resource(path).get(&block) end |
#head(path, &block) ⇒ Object
145 146 147 |
# File 'lib/useless/doc/dsl.rb', line 145 def head(path, &block) resource(path).head(&block) end |
#name ⇒ Object
121 122 123 |
# File 'lib/useless/doc/dsl.rb', line 121 def name @attributes[:name] = name end |
#patch(path, &block) ⇒ Object
157 158 159 |
# File 'lib/useless/doc/dsl.rb', line 157 def patch(path, &block) resource(path).patch(&block) end |
#post(path, &block) ⇒ Object
149 150 151 |
# File 'lib/useless/doc/dsl.rb', line 149 def post(path, &block) resource(path).post(&block) end |
#put(path, &block) ⇒ Object
153 154 155 |
# File 'lib/useless/doc/dsl.rb', line 153 def put(path, &block) resource(path).put(&block) end |
#resource(path, &block) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/useless/doc/dsl.rb', line 173 def resource(path, &block) resource_dsl = @resource_dsls.find do |resource| resource.attributes[:path] == path end unless resource_dsl resource_dsl = Resource.new(path: path) @resource_dsls << resource_dsl end resource_dsl.instance_eval(&block) if block_given? resource_dsl end |
#timestamp(timestamp) ⇒ Object
133 134 135 136 137 138 139 |
# File 'lib/useless/doc/dsl.rb', line 133 def () if .is_a?(String) = Time.parse() end @attributes[:timestamp] = end |
#trace(path, &block) ⇒ Object
165 166 167 |
# File 'lib/useless/doc/dsl.rb', line 165 def trace(path, &block) resource(path).trace(&block) end |
#url(url) ⇒ Object
125 126 127 |
# File 'lib/useless/doc/dsl.rb', line 125 def url(url) @attributes[:url] = url end |