Class: MkAcl::Generator
- Inherits:
-
Object
- Object
- MkAcl::Generator
- Defined in:
- lib/mikras_utils/mkacl/generators/role_functions.rb,
lib/mikras_utils/mkacl/generator.rb,
lib/mikras_utils/mkacl/generators/rules.rb,
lib/mikras_utils/mkacl/generators/seeds.rb,
lib/mikras_utils/mkacl/generators/id_functions.rb,
lib/mikras_utils/mkacl/generators/acl_functions.rb,
lib/mikras_utils/mkacl/generators/insert_triggers.rb
Overview
Generates the functions
acl_portal.user_is_role(_user_id integer, _object_id integer, _roles text[])
acl_portal.user_is_role(_user_id integer, _object_id integer, _roles text)
Returns true if the user has one of the given roles on the domain
object
public.current_is_role(_object_id integer, _roles text[])
public.current_is_role(_object_id integer, _roles text)
Returns true if the current user has one of the given roles on the
domain object
public.current_is_ROLE(_object_id integer)
ROLE is one of the role kinds. Returns true if the current user has the
given role
Defined Under Namespace
Classes: AclFunctions, IdFunctions, InsertTriggers, RoleFunctions, Rules, Seeds
Constant Summary collapse
- MODULES =
[:id_functions, :insert_triggers, :rules, :acl_functions, :role_functions, :seeds]
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Class Method Summary collapse
Instance Method Summary collapse
- #generate(modules = MODULES, interactive: true) ⇒ Object
-
#initialize(spec, conn) ⇒ Generator
constructor
A new instance of Generator.
- #inspect ⇒ Object
Constructor Details
#initialize(spec, conn) ⇒ Generator
Returns a new instance of Generator.
19 20 21 22 |
# File 'lib/mikras_utils/mkacl/generator.rb', line 19 def initialize(spec, conn) @spec = spec @conn = conn end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
16 17 18 |
# File 'lib/mikras_utils/mkacl/generator.rb', line 16 def conn @conn end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
15 16 17 |
# File 'lib/mikras_utils/mkacl/generator.rb', line 15 def spec @spec end |
Class Method Details
.generate(spec, conn, modules = MODULES, **opts) ⇒ Object
46 47 48 |
# File 'lib/mikras_utils/mkacl/generator.rb', line 46 def self.generate(spec, conn, modules = MODULES, **opts) self.new(spec, conn).generate(modules, **opts) end |
Instance Method Details
#generate(modules = MODULES, interactive: true) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mikras_utils/mkacl/generator.rb', line 24 def generate(modules = MODULES, interactive: true) if interactive puts "\\set ON_ERROR_STOP on" puts else puts "-- Auto-generated by mkacl(1) - please don't touch" puts "--" puts end matches = modules.map { |k| [k, true] }.to_h Seeds.generate(self) if matches.key?(:seeds) IdFunctions.generate(self) if matches.key?(:id_functions) for table in spec.tables InsertTriggers.generate(self, table) if matches.key?(:insert_triggers) end Rules.generate(self) if matches.key?(:rules) AclFunctions.generate(self) if matches.key?(:acl_functions) RoleFunctions.generate(self) if matches.key?(:role_functions) end |
#inspect ⇒ Object
50 |
# File 'lib/mikras_utils/mkacl/generator.rb', line 50 def inspect() "Generator(#{@database.inspect}, #{@username.inspect}, #{@spec})" end |