Module: CanvasSync::Record

Class Method Summary collapse

Methods included from Concerns::SyncMapping

mapping_for

Class Method Details

._get_module_parent(modul) ⇒ Object



30
31
32
# File 'lib/canvas_sync/record.rb', line 30

def self._get_module_parent(modul)
  modul.respond_to?(:parent) ? modul.parent : modul.module_parent
end

.define_feature(modul, feature_ident = nil, models: nil, default: false, &blk) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/canvas_sync/record.rb', line 13

def self.define_feature(modul, feature_ident = nil, models: nil, default: false, &blk)
  feature_ident = modul.name.demodulize.underscore if feature_ident.nil?
  if models == nil
    pmod = _get_module_parent(modul)
    models = pmod.name.demodulize if pmod && _get_module_parent(pmod) == CanvasSync::Concerns
  end

  @canvas_sync_features ||= {}
  @canvas_sync_features[feature_ident] = {
    name: feature_ident,
    module: modul,
    default: default,
    models: Array.wrap(models).map(&:to_s),
    setup: blk || ->{ include modul },
  }
end

.registered_featuresObject



9
10
11
# File 'lib/canvas_sync/record.rb', line 9

def self.registered_features
  @canvas_sync_features ||= {}
end