Sha256: 83188e200cee8b5114614a82316f9b1de63e4055de8a47f29232fe428bffd0cd

Contents?: true

Size: 1002 Bytes

Versions: 4

Compression:

Stored size: 1002 Bytes

Contents

module Eco::Data::Locations
  NODE_PLAIN_ATTRS = %i[row_num id name parent_id weight archived archive_token]
  NodePlainStruct  = Struct.new(*NODE_PLAIN_ATTRS)
  # Class to treat input csv in a form of a list of nodes, where parent is specified.
  class NodePlain < NodePlainStruct
    include Eco::Data::Locations::NodeBase

    require_relative 'node_plain/parsing'
    require_relative 'node_plain/serial'
    require_relative 'node_plain/builder'
    extend Eco::Data::Locations::NodePlain::Builder

    ALL_ATTRS          = NODE_PLAIN_ATTRS
    ADDITIONAL_ATTRS   = %i[row_num]
    PROP_ATTRS         = ALL_ATTRS - ADDITIONAL_ATTRS

    def id
      clean_id(super, ref: "(Row: #{self.row_num}) ")
    end
    # backwards compatibility
    alias_method :tag, :id

    def name
      super || self.id
    end

    def parent_id
      clean_id(super, notify: false, ref: "(Row: #{self.row_num} - parent_id) ")
    end
    alias_method :parentId, :parent_id
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eco-helpers-2.6.4 lib/eco/data/locations/node_plain.rb
eco-helpers-2.6.3 lib/eco/data/locations/node_plain.rb
eco-helpers-2.6.2 lib/eco/data/locations/node_plain.rb
eco-helpers-2.6.1 lib/eco/data/locations/node_plain.rb