Class: Unimatrix::BlueprintOperation
- Defined in:
- lib/unimatrix/blueprint_operation.rb
Constant Summary collapse
- @@blueprints =
{}
Instance Method Summary collapse
-
#initialize(realm_uuid, options = {}) ⇒ BlueprintOperation
constructor
A new instance of BlueprintOperation.
- #read ⇒ Object
Methods inherited from Operation
#destroy, #include, #key, #limit, #offset, #read_in_batches, #where, #write
Constructor Details
#initialize(realm_uuid, options = {}) ⇒ BlueprintOperation
Returns a new instance of BlueprintOperation.
7 8 9 10 |
# File 'lib/unimatrix/blueprint_operation.rb', line 7 def initialize( realm_uuid, = {} ) @realm_uuid = realm_uuid super( "/realms/#{ realm_uuid }/blueprints", ) end |
Instance Method Details
#read ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/unimatrix/blueprint_operation.rb', line 12 def read @@blueprints[ @realm_uuid ] ||= begin blueprints = [] offset = 0 segment_count = 10 total = nil errors = nil while total.nil? || offset < total operation = self.offset( offset ).include( 'blueprint_attributes' ) operation.read do | resources, response | if !response.body[ 'errors' ].nil? errors = response.body[ 'errors' ] break end offset += segment_count total = response.body[ '$this' ][ 'unlimited_count' ] blueprints += resources end raise "Error requesting blueprints for realm #{ @realm_uuid }. Error: #{ errors }" if !errors.nil? end blueprints end end |