Class: BucketsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BucketsController
- Defined in:
- app/controllers/buckets_controller.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #fork ⇒ Object
- #last ⇒ Object
- #last_response ⇒ Object
- #record ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#clear ⇒ Object
24 25 26 27 28 |
# File 'app/controllers/buckets_controller.rb', line 24 def clear bucket.clear_history redirect_to bucket_path(bucket.token) end |
#create ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/controllers/buckets_controller.rb', line 6 def create new_bucket = { owner_token: owner_token } new_bucket[:user_id] = current_user.id if user_signed_in? bucket = Bucket.create(new_bucket) redirect_to bucket_path(bucket.token) end |
#destroy ⇒ Object
30 31 32 33 34 |
# File 'app/controllers/buckets_controller.rb', line 30 def destroy bucket.destroy redirect_to root_path end |
#fork ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/controllers/buckets_controller.rb', line 15 def fork forked_bucket = Bucket.create(owner_token: owner_token, response_builder: bucket.response_builder, name: "Copy of #{bucket.name}", fork: bucket) redirect_to bucket_path(forked_bucket.token) end |
#last ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'app/controllers/buckets_controller.rb', line 49 def last return render_request_not_found unless last_request = bucket.last_request respond_to do |format| format.html { render text: last_request.body } format.json { render json: JSON.pretty_generate(last_request.attributes) } end end |
#last_response ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'app/controllers/buckets_controller.rb', line 58 def last_response return render_request_not_found unless last_response = bucket.last_response respond_to do |format| format.html { render text: last_response.body } format.json { render json: JSON.pretty_generate(last_response.attributes) } end end |
#record ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/buckets_controller.rb', line 67 def record result = RecordRequest.call(bucket: bucket, rack_request: request) recorded_response = result.response response.headers.merge! recorded_response.headers.to_h render text: body_as_string(recorded_response), status: recorded_response.status end |
#show ⇒ Object
36 37 38 |
# File 'app/controllers/buckets_controller.rb', line 36 def show @requests = bucket.requests.page(params[:page]).per 1 end |
#update ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'app/controllers/buckets_controller.rb', line 40 def update update_bucket = bucket_params update_bucket[:user_id] = current_user.id if user_signed_in? bucket.update_attributes update_bucket redirect_to bucket_path(bucket.token) end |