Class: Ecoportal::API::V2::Page::PermissionFlags

Inherits:
Common::Content::DoubleModel show all
Defined in:
lib/ecoportal/api/v2/page/permission_flags.rb

Constant Summary

Constants included from Common::Content::DoubleModel::Diffable

Common::Content::DoubleModel::Diffable::DIFF_CLASS

Constants included from Common::Content::DoubleModel::Base

Common::Content::DoubleModel::Base::NOT_USED

Instance Attribute Summary

Attributes included from Common::Content::DoubleModel::Parented

#_parent, #_parent_key

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Common::Content::DoubleModel

#initialize, new_uuid

Methods included from Common::Content::DoubleModel::Diffable

#as_update, #dirty?

Methods included from Common::Content::Includer

#include_missing

Constructor Details

This class inherits a constructor from Ecoportal::API::Common::Content::DoubleModel

Class Method Details

.new_docObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ecoportal/api/v2/page/permission_flags.rb', line 7

def new_doc
  {
    "can_restructure"          => false,
    "can_configure"            => false,
    "can_permission"           => false,
    "can_create_actions"       => false,
    "can_administrate_actions" => false,
    "subscribed"               => false,
    "subscribed_to_tasks"      => false
  }
end

Instance Method Details

#configure(*conf) ⇒ Object

Quick config helper

Parameters:

  • conf (Symbol, Array<Symbol>)
    • :restructure
    • :configure
    • :can_permission
    • :create_actions
    • :admin_actions
    • :subscribed
    • :subscribed_to_tasks


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ecoportal/api/v2/page/permission_flags.rb', line 37

def configure(*conf)
  conf.each_with_object([]) do |cnf, unused|
    if cnf.is_a?(Symbol)
      set_flag(cnf, true, residual: unused)
    elsif cnf.is_a?(Hash)
      cnf.each do |key, val|
        set_flag(key, val, residual: unused)
      end
    else
      raise ArgumentError.new("Expecting 'Symbol' or 'Hash'. Given: #{cnf.class}")
    end
  end.yield_self do |unused|
    raise ArgumentError.new("Unknown configuaration options #{unused}") unless unused.empty?
  end
end

#reset!Object



24
25
26
# File 'lib/ecoportal/api/v2/page/permission_flags.rb', line 24

def reset!
  doc.merge!(self.class.new_doc)
end