Class: Dawn::App::Drains
- Inherits:
-
Object
- Object
- Dawn::App::Drains
- Includes:
- BaseApi, Enumerable
- Defined in:
- lib/dawn/api/models/app/drains.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #all(options = {}) ⇒ Array<Dawn::Drain>
- #create(options = {}) ⇒ Dawn::Drain
- #destroy(options) ⇒ Object
- #each({ |drain| do_stuff_with_drain }) ⇒ Object
- #find(options = {}) ⇒ Dawn::Drain
-
#initialize(app) ⇒ Drains
constructor
A new instance of Drains.
- #to_a ⇒ Array<Dawn::Drain>
Methods included from BaseApi
Methods included from BaseApi::RequestExtension
Methods included from SafeExtension
Constructor Details
#initialize(app) ⇒ Drains
Returns a new instance of Drains.
15 16 17 |
# File 'lib/dawn/api/models/app/drains.rb', line 15 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
10 11 12 |
# File 'lib/dawn/api/models/app/drains.rb', line 10 def app @app end |
Instance Method Details
#all(options = {}) ⇒ Array<Dawn::Drain>
48 49 50 51 52 53 |
# File 'lib/dawn/api/models/app/drains.rb', line 48 def all(={}) get( path: "/apps/#{app.id}/drains", query: ).map { |hsh| Drain.new(hsh["drain"]).tap { |d| d.app = @app } } end |
#create(options = {}) ⇒ Dawn::Drain
36 37 38 39 40 41 42 43 |
# File 'lib/dawn/api/models/app/drains.rb', line 36 def create(={}) .fetch(:drain) Drain.new(post( path: "/apps/#{app.id}/drains", body: .to_json )["drain"]).tap { |d| d.app = @app } end |
#destroy(options) ⇒ Object
62 63 64 |
# File 'lib/dawn/api/models/app/drains.rb', line 62 def destroy() Drain.destroy() end |
#each({ |drain| do_stuff_with_drain }) ⇒ Object
29 30 31 |
# File 'lib/dawn/api/models/app/drains.rb', line 29 def each(&block) all.each(&block) end |
#find(options = {}) ⇒ Dawn::Drain
58 59 60 |
# File 'lib/dawn/api/models/app/drains.rb', line 58 def find(={}) Drain.find().tap { |d| d.app = @app } end |
#to_a ⇒ Array<Dawn::Drain>
22 23 24 |
# File 'lib/dawn/api/models/app/drains.rb', line 22 def to_a all end |