Sha256: 87cdbe7a0dca8eb4f0ffd29fba24b94b3aaf0552f676fff7239cdc2201819a25

Contents?: true

Size: 640 Bytes

Versions: 14

Compression:

Stored size: 640 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module EacRailsUtils
  module DataTableHelper
    class ColumnNode
      common_constructor :node, :path

      # @return [Boolean]
      def ended?
        node.nil? || path.empty?
      end

      # @return [Object]
      def value
        ended? ? node : child_value
      end

      private

      # @return [Object]
      def child_value
        subpath = path.dup
        n = subpath.shift
        return self.class.new(node.send(n), subpath).value if node.respond_to?(n)

        raise "Instance of #{node.class} does not respond to #{n}"
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
eac_rails_utils-0.25.0 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.24.0 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.23.4 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.23.3 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.23.2 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.23.1 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.23.0 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.22.3 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.22.2 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.22.1 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.22.0 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.21.0 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.20.0 app/helpers/eac_rails_utils/data_table_helper/column_node.rb
eac_rails_utils-0.19.0 app/helpers/eac_rails_utils/data_table_helper/column_node.rb