Class: Casbin::Model::FunctionMap

Inherits:
Object
  • Object
show all
Defined in:
lib/casbin-ruby/model/function_map.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFunctionMap

Returns a new instance of FunctionMap.



6
7
8
# File 'lib/casbin-ruby/model/function_map.rb', line 6

def initialize
  @fm = {}
end

Instance Attribute Details

#fmObject (readonly) Also known as: get_functions

Returns the value of attribute fm.



10
11
12
# File 'lib/casbin-ruby/model/function_map.rb', line 10

def fm
  @fm
end

Class Method Details

.load_function_mapObject

It might be better to move this to initialize



18
19
20
21
22
23
24
25
26
27
# File 'lib/casbin-ruby/model/function_map.rb', line 18

def self.load_function_map
  fm = FunctionMap.new
  fm.add_function('keyMatch', ->(*args) { Util::BuiltinOperators.key_match_func(*args) })
  fm.add_function('keyMatch2', ->(*args) { Util::BuiltinOperators.key_match2_func(*args) })
  fm.add_function('regexMatch', ->(*args) { Util::BuiltinOperators.regex_match_func(*args) })
  fm.add_function('ipMatch', ->(*args) { Util::BuiltinOperators.ip_match_func(*args) })
  fm.add_function('globMatch', ->(*args) { Util::BuiltinOperators.glob_match_func(*args) })

  fm
end

Instance Method Details

#add_function(name, func) ⇒ Object



13
14
15
# File 'lib/casbin-ruby/model/function_map.rb', line 13

def add_function(name, func)
  fm[name] = func
end