module Ecoportal module API class V2 class Page class PermissionFlags < Common::Content::DoubleModel class << self 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 end passboolean :can_restructure, :can_configure passboolean :can_permission, :can_create_actions, :can_administrate_actions passboolean :subscribed, :subscribed_to_tasks def reset! doc.merge!(self.class.new_doc) end # Quick config helper # @param conf [Symbol, Array] # - `:restructure` # - `:configure` # - `:can_permission` # - `:create_actions` # - `:admin_actions` # - `:subscribed` # - `:subscribed_to_tasks` def configure(*conf) conf.each_with_object([]) do |cnf, unused| case cnf when :restructure self.can_restructure = true when :configure self.can_configure = true when :can_permission self.can_permission = true when :create_actions self.can_create_actions = true when :admin_actions self.can_administrate_actions = true when :subscribed self.subscribed = true when :subscribed_to_tasks self.subscribed_to_tasks = true else unused.push(cnf) end end.yield_self do |unused| raise "Unknown configuaration options #{unused}" unless unused.empty? end end end end end end end