Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/mumuki/classroom/permissions_diff.rb,
lib/mumuki/classroom/models/concerns/extensions.rb

Instance Method Summary collapse

Instance Method Details

#deep_compactObject



33
34
35
36
37
38
39
40
41
# File 'lib/mumuki/classroom/models/concerns/extensions.rb', line 33

def deep_compact
  compact
  each_pair do |k, v|
    if self[k].respond_to? :deep_compact
      self[k].deep_compact
    end
    self.delete(k) if self[k].nil?
  end
end

#merge_if(criterion, hash) ⇒ Object



48
49
50
51
# File 'lib/mumuki/classroom/models/concerns/extensions.rb', line 48

def merge_if(criterion, hash)
  return merge hash if criterion
  self
end

#merge_unless(criterion, hash) ⇒ Object



43
44
45
46
# File 'lib/mumuki/classroom/models/concerns/extensions.rb', line 43

def merge_unless(criterion, hash)
  return merge hash unless criterion
  self
end

#to_mumukit_permissionsObject



2
3
4
# File 'lib/mumuki/classroom/permissions_diff.rb', line 2

def to_mumukit_permissions
  Mumukit::Auth::Permissions.parse self
end