Class: Streaker::Box
- Inherits:
-
Object
- Object
- Streaker::Box
- Defined in:
- lib/streaker/box.rb
Overview
Represents a Streak Box through the API.
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
-
.create(name:, pipeline: :default, assigned_to: [], **attributes) ⇒ Object
Create a Streak box: box = Box.create( pipeline: :some_pipeline_name, name: ‘Some box name’, stage: :some_stage, some_field_key: ‘Some field value’, … ).
Instance Method Summary collapse
-
#initialize(key) ⇒ Box
constructor
A new instance of Box.
-
#update(attributes) ⇒ Object
Update data for a box: box = Box.new(‘someboxkey’) box.update( name: ‘Some box name’, stage: :some_stage, some_field_key: ‘Some field value’, … ).
Constructor Details
#initialize(key) ⇒ Box
Returns a new instance of Box.
9 10 11 |
# File 'lib/streaker/box.rb', line 9 def initialize(key) @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/streaker/box.rb', line 7 def key @key end |
Class Method Details
.create(name:, pipeline: :default, assigned_to: [], **attributes) ⇒ Object
Create a Streak box:
box = Box.create(
pipeline: :some_pipeline_name,
name: 'Some box name',
stage: :some_stage,
some_field_key: 'Some field value',
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/streaker/box.rb', line 38 def self.create(name:, pipeline: :default, assigned_to: [], **attributes) api = Streaker::API.new api_result = api.create_box( pipeline_key(pipeline), name: name, assigned_to: assigned_to ) raise Streaker::Box::Error, api_result['error'] if api_result['error'] api.update_box(api_result['key'], name: name, **attributes) new(api_result['key']) end |
Instance Method Details
#update(attributes) ⇒ Object
Update data for a box:
box = Box.new('someboxkey')
box.update(
name: 'Some box name',
stage: :some_stage,
some_field_key: 'Some field value',
21 22 23 24 25 26 27 28 |
# File 'lib/streaker/box.rb', line 21 def update(attributes) verify_if_box_exists api_result = api.update_box(key, attributes) raise Streaker::Box::Error, api_result['error'] if api_result['error'] true end |