Class: Core::Service::Request
- Inherits:
-
Object
- Object
- Core::Service::Request
- Extended by:
- Initializable
- Includes:
- Benchmarking, References, EndpointHandling
- Defined in:
- app/api/core/service.rb
Overview
rubocop:todo Style/Documentation
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, *args, &block) ⇒ Request
constructor
A new instance of Request.
-
#push(value) ⇒ Object
Safe way to push a particular value on to the request target stack.
- #response(&block) ⇒ 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
#initialize(identifier, *args, &block) ⇒ Request
Returns a new instance of Request.
128 129 130 131 132 |
# File 'app/api/core/service.rb', line 128 def initialize(identifier, *args, &block) @identifier, @started_at = identifier, Time.zone.now super(*args, &block) @ability = Core::Abilities.create(self) end |
Instance Attribute Details
#ability ⇒ Object (readonly)
Returns the value of attribute ability
124 125 126 |
# File 'app/api/core/service.rb', line 124 def ability @ability end |
#file=(value) ⇒ Object (writeonly)
Sets the attribute file
123 124 125 |
# File 'app/api/core/service.rb', line 123 def file=(value) @file = value end |
#filename=(value) ⇒ Object (writeonly)
Sets the attribute filename
123 124 125 |
# File 'app/api/core/service.rb', line 123 def filename=(value) @filename = value end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier
124 125 126 |
# File 'app/api/core/service.rb', line 124 def identifier @identifier end |
#io=(value) ⇒ Object (writeonly)
Sets the attribute io
123 124 125 |
# File 'app/api/core/service.rb', line 123 def io=(value) @io = value end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at
124 125 126 |
# File 'app/api/core/service.rb', line 124 def started_at @started_at end |
Instance Method Details
#attributes(_object = nil) ⇒ Object
158 159 160 |
# File 'app/api/core/service.rb', line 158 def attributes(_object = nil) io.map_parameters_to_attributes(json, nil) end |
#authentication_code ⇒ Object
138 139 140 141 142 143 |
# File 'app/api/core/service.rb', line 138 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
134 135 136 |
# File 'app/api/core/service.rb', line 134 def @service.request.env['HTTP_X_SEQUENCESCAPE_CLIENT_ID'] end |
#create!(instance_attributes = attributes) ⇒ Object
162 163 164 165 166 167 |
# File 'app/api/core/service.rb', line 162 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.
151 152 153 154 155 156 |
# File 'app/api/core/service.rb', line 151 def push(value) target_before, @target = @target, value yield ensure @target = target_before end |
#response(&block) ⇒ Object
145 146 147 |
# File 'app/api/core/service.rb', line 145 def response(&block) ::Core::Service::Response.new(self, &block) end |
#update!(instance_attributes = attributes) ⇒ Object
169 170 171 172 173 |
# File 'app/api/core/service.rb', line 169 def update!(instance_attributes = attributes) ActiveRecord::Base.transaction do target.tap { |o| o.update!(instance_attributes) } end end |