Sha256: c88fe96200bf198edd57a286c923f86d7301d6a4f1207336907d5c0e66938f53
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
module ForestAdminDatasourceToolkit class Collection < Components::Contracts::CollectionContract attr_reader :actions, :datasource, :name, :schema, :native_driver def initialize(datasource, name, native_driver = nil) super() @datasource = datasource @name = name @native_driver = native_driver @schema = { fields: {}, countable: false, searchable: false, charts: [], segments: {} } @actions = {} end def enable_count schema[:countable] = true end def is_countable? schema[:countable] end def is_searchable? schema[:searchable] end def fields schema[:fields] end def add_field(name, field) raise Exceptions::ForestException, "Field #{name} already defined in collection" if @schema[:fields].key?(name) schema[:fields][name] = field end def add_fields(fields) fields.each do |name, field| add_field(name, field) end end def add_action(name, action) raise Exceptions::ForestException, "Action #{name} already defined in collection" if @actions[key] @actions[name] = action end def render_chart(_caller, name, _record_id) raise Exceptions::ForestException, "Chart #{name} is not implemented." end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
forest_admin_datasource_toolkit-1.0.0.pre.beta.53 | lib/forest_admin_datasource_toolkit/collection.rb |