Module: Locomotive::Steam::Adapters::Filesystem::Sanitizer

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



11
12
13
# File 'lib/locomotive/steam/adapters/filesystem/sanitizer.rb', line 11

def scope
  @scope
end

Instance Method Details

#apply_to(entity_or_dataset) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/locomotive/steam/adapters/filesystem/sanitizer.rb', line 23

def apply_to(entity_or_dataset)
  if entity_or_dataset.respond_to?(:all)
    apply_to_dataset(entity_or_dataset)
  else
    apply_to_entity(entity_or_dataset)
  end
end

#apply_to_dataset(dataset) ⇒ Object



31
32
33
# File 'lib/locomotive/steam/adapters/filesystem/sanitizer.rb', line 31

def apply_to_dataset(dataset)
  dataset
end

#apply_to_entity(entity) ⇒ Object



35
36
37
38
# File 'lib/locomotive/steam/adapters/filesystem/sanitizer.rb', line 35

def apply_to_entity(entity)
  attach_site_to(entity)
  entity
end

#apply_to_entity_with_dataset(entity, dataset) ⇒ Object



40
41
42
# File 'lib/locomotive/steam/adapters/filesystem/sanitizer.rb', line 40

def apply_to_entity_with_dataset(entity, dataset)
  entity
end

#attach_site_to(entity) ⇒ Object



44
45
46
# File 'lib/locomotive/steam/adapters/filesystem/sanitizer.rb', line 44

def attach_site_to(entity)
  entity[:site_id] = scope.site._id if scope.site
end

#setup(scope) ⇒ Object



13
14
15
16
# File 'lib/locomotive/steam/adapters/filesystem/sanitizer.rb', line 13

def setup(scope)
  @scope = scope
  self
end

#with(scope) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



18
19
20
21
# File 'lib/locomotive/steam/adapters/filesystem/sanitizer.rb', line 18

def with(scope, &block)
  setup(scope)
  yield(self)
end