Sha256: 14dcd07d8e10a40fb76c3f314c21ed55e0671d4294886ca726986c67367f292f
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
# encoding: utf-8 # module Mode module Sdk # Represents a set of Mode::Column instances # class ColumnSet attr_reader :original_columns # Construct a new ColumnSet instance # # @param original_columns [Array<Hash>] an array of hashes defining # column names and types # # @return [Mode::Sdk::ColumnSet] the instance # def initialize(original_columns) @original_columns = original_columns end # Build an array of Mode::Sdk::Column instances # # @return [Array<Mode::Sdk::Column>] array of columns # def columns @columns ||= (original_columns || []).map do |column| Mode::Sdk::Column.new(column) end end # Validate the provided columns # # @raise [Mode::Sdk::ColumnSet::InvalidError] if no columns are provided # # @return [true] # def validate! fail InvalidError, 'No columns provided' unless columns.any? columns.each(&:validate!) true end # Convert columns to array of hashes # # @return [Array<Hash>] array of column attribute hashes # def to_array columns.map(&:attributes) end class InvalidError < StandardError; end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mode-sdk-0.1.0 | lib/mode/sdk/column_set.rb |
mode-sdk-0.0.1 | lib/mode/sdk/column_set.rb |