Class: Casbin::Model::FunctionMap
- Inherits:
-
Object
- Object
- Casbin::Model::FunctionMap
- Defined in:
- lib/casbin-ruby/model/function_map.rb
Instance Attribute Summary collapse
-
#fm ⇒ Object
(also: #get_functions)
readonly
Returns the value of attribute fm.
Class Method Summary collapse
-
.load_function_map ⇒ Object
It might be better to move this to initialize.
Instance Method Summary collapse
- #add_function(name, func) ⇒ Object
-
#initialize ⇒ FunctionMap
constructor
A new instance of FunctionMap.
Constructor Details
#initialize ⇒ FunctionMap
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
#fm ⇒ Object (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_map ⇒ Object
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 |