Class: ShopifyTransporter::Shopify::Record
- Inherits:
-
Object
- Object
- ShopifyTransporter::Shopify::Record
- Defined in:
- lib/shopify_transporter/shopify/record.rb
Constant Summary collapse
- METAFIELD_PREFIX =
'metafield_'- METAFIELD_ATTRIBUTES =
%w(namespace key value value_type).freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Record
constructor
A new instance of Record.
- #metafield_row_values ⇒ Object
- #to_csv ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Record
Returns a new instance of Record.
9 10 11 |
# File 'lib/shopify_transporter/shopify/record.rb', line 9 def initialize(hash = {}) @record_hash = hash end |
Class Method Details
.columns ⇒ Object
37 38 39 |
# File 'lib/shopify_transporter/shopify/record.rb', line 37 def columns raise NotImplementedError end |
.has_values?(hash) ⇒ Boolean
45 46 47 |
# File 'lib/shopify_transporter/shopify/record.rb', line 45 def has_values?(hash) hash.except(*keys).any? { |_, v| v } end |
.header ⇒ Object
23 24 25 |
# File 'lib/shopify_transporter/shopify/record.rb', line 23 def header raise NotImplementedError end |
.keys ⇒ Object
41 42 43 |
# File 'lib/shopify_transporter/shopify/record.rb', line 41 def keys raise NotImplementedError end |
Instance Method Details
#metafield_row_values ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/shopify_transporter/shopify/record.rb', line 13 def return [] if @record_hash['metafields'].blank? @record_hash['metafields'].map do || = .slice(*METAFIELD_ATTRIBUTES) .transform_keys! { |k| "#{METAFIELD_PREFIX}#{k}" } row_values_from() if self.class.has_values?() end.compact end |
#to_csv ⇒ Object
28 29 30 |
# File 'lib/shopify_transporter/shopify/record.rb', line 28 def to_csv raise NotImplementedError end |