Class: Core::Service::Request
- Inherits:
-
Object
- Object
- Core::Service::Request
- Extended by:
- Initializable
- Includes:
- Benchmarking, References, EndpointHandling
- Defined in:
- app/api/core/service.rb
Instance Attribute Summary collapse
-
#ability ⇒ Object
readonly
Returns the value of attribute ability.
-
#file ⇒ Object
writeonly
Sets the attribute file.
-
#filename ⇒ Object
writeonly
Sets the attribute filename.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#io ⇒ Object
writeonly
Sets the attribute io.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
Instance Method Summary collapse
- #attributes(_object = nil) ⇒ Object
- #authentication_code ⇒ Object
- #authorisation_code ⇒ Object
- #create!(instance_attributes = attributes) ⇒ Object
-
#initialize(identifier) ⇒ Request
constructor
A new instance of Request.
-
#push(value) ⇒ Object
Safe way to push a particular value on to the request target stack.
- #response ⇒ Object
- #update!(instance_attributes = attributes) ⇒ Object
Methods included from Initializable
extended, initialized_attr_reader, initialized_delegate
Methods included from EndpointHandling
Methods included from Benchmarking
Constructor Details
Instance Attribute Details
#ability ⇒ Object (readonly)
Returns the value of attribute ability.
125 126 127 |
# File 'app/api/core/service.rb', line 125 def ability @ability end |
#file=(value) ⇒ Object (writeonly)
Sets the attribute file
124 125 126 |
# File 'app/api/core/service.rb', line 124 def file=(value) @file = value end |
#filename=(value) ⇒ Object (writeonly)
Sets the attribute filename
124 125 126 |
# File 'app/api/core/service.rb', line 124 def filename=(value) @filename = value end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
125 126 127 |
# File 'app/api/core/service.rb', line 125 def identifier @identifier end |
#io=(value) ⇒ Object (writeonly)
Sets the attribute io
124 125 126 |
# File 'app/api/core/service.rb', line 124 def io=(value) @io = value end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
125 126 127 |
# File 'app/api/core/service.rb', line 125 def started_at @started_at end |
Instance Method Details
#attributes(_object = nil) ⇒ Object
159 160 161 |
# File 'app/api/core/service.rb', line 159 def attributes(_object = nil) io.map_parameters_to_attributes(json, nil) end |
#authentication_code ⇒ Object
139 140 141 142 143 144 |
# File 'app/api/core/service.rb', line 139 def authentication_code # The WTSISignOn service has been retired. However previously the code # supported supplying the API key in this cookie, so this has been left # for compatibility purposes @service.request.['api_key'] || @service.request.['WTSISignOn'] end |
#authorisation_code ⇒ Object
135 136 137 |
# File 'app/api/core/service.rb', line 135 def @service.request.env['HTTP_X_SEQUENCESCAPE_CLIENT_ID'] end |
#create!(instance_attributes = attributes) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 |
# File 'app/api/core/service.rb', line 163 def create!(instance_attributes = attributes) ActiveRecord::Base.transaction do record = target.create!(instance_attributes) ::Core::Io::Registry .instance .lookup_for_object(record) .eager_loading_for(record.class) .include_uuid .find(record.id) end end |
#push(value) ⇒ Object
Safe way to push a particular value on to the request target stack. Ensures that the original value is reset when the block is exitted.
152 153 154 155 156 157 |
# File 'app/api/core/service.rb', line 152 def push(value) target_before, @target = @target, value yield ensure @target = target_before end |
#response ⇒ Object
146 147 148 |
# File 'app/api/core/service.rb', line 146 def response(&) ::Core::Service::Response.new(self, &) end |
#update!(instance_attributes = attributes) ⇒ Object
175 176 177 |
# File 'app/api/core/service.rb', line 175 def update!(instance_attributes = attributes) ActiveRecord::Base.transaction { target.tap { |o| o.update!(instance_attributes) } } end |