Class: TurbineRb::Client::App::Collection
- Inherits:
-
Object
- Object
- TurbineRb::Client::App::Collection
- Defined in:
- lib/turbine_rb/client.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pb_records ⇒ Object
Returns the value of attribute pb_records.
-
#pb_stream ⇒ Object
Returns the value of attribute pb_stream.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, records, stream, app) ⇒ Collection
constructor
A new instance of Collection.
- #process_with(process:) ⇒ Object
- #records ⇒ Object
- #unwrap ⇒ Object
- #write_to(resource:, collection:, configs: nil) ⇒ Object
Constructor Details
#initialize(name, records, stream, app) ⇒ Collection
Returns a new instance of Collection.
107 108 109 110 111 112 |
# File 'lib/turbine_rb/client.rb', line 107 def initialize(name, records, stream, app) @name = name @pb_records = records @pb_stream = stream @app = app end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
99 100 101 |
# File 'lib/turbine_rb/client.rb', line 99 def app @app end |
#name ⇒ Object
Returns the value of attribute name.
99 100 101 |
# File 'lib/turbine_rb/client.rb', line 99 def name @name end |
#pb_records ⇒ Object
Returns the value of attribute pb_records.
99 100 101 |
# File 'lib/turbine_rb/client.rb', line 99 def pb_records @pb_records end |
#pb_stream ⇒ Object
Returns the value of attribute pb_stream.
99 100 101 |
# File 'lib/turbine_rb/client.rb', line 99 def pb_stream @pb_stream end |
Class Method Details
.unwrap(collection) ⇒ Object
101 102 103 104 105 |
# File 'lib/turbine_rb/client.rb', line 101 def self.unwrap(collection) return collection.unwrap if collection.instance_of?(Collection) collection end |
Instance Method Details
#process_with(process:) ⇒ Object
118 119 120 |
# File 'lib/turbine_rb/client.rb', line 118 def process_with(process:) app.process(records: self, process: process) end |
#records ⇒ Object
122 123 124 125 126 |
# File 'lib/turbine_rb/client.rb', line 122 def records return pb_records.to_a if pb_records.respond_to?(:to_a) [pb_records].compact.flatten end |
#unwrap ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/turbine_rb/client.rb', line 128 def unwrap TurbineCore::Collection.new( # convert back to TurbineCore::Collection name: name, records: records, stream: pb_stream ) end |
#write_to(resource:, collection:, configs: nil) ⇒ Object
114 115 116 |
# File 'lib/turbine_rb/client.rb', line 114 def write_to(resource:, collection:, configs: nil) resource.write(records: self, collection: collection, configs: configs) end |