Class: ChefFixie::AuthzMapper::ReverseMapper
- Inherits:
-
Object
- Object
- ChefFixie::AuthzMapper::ReverseMapper
- Defined in:
- lib/chef_fixie/authz_mapper.rb
Instance Attribute Summary collapse
-
#by_type ⇒ Object
readonly
Returns the value of attribute by_type.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Instance Method Summary collapse
- #authz_to_name(authz_id, ctype = nil) ⇒ Object
- #class_cache(klass) ⇒ Object
- #dump ⇒ Object
-
#initialize ⇒ ReverseMapper
constructor
A new instance of ReverseMapper.
- #register(klass, name, type) ⇒ Object
Constructor Details
#initialize ⇒ ReverseMapper
Returns a new instance of ReverseMapper.
62 63 64 65 66 67 68 |
# File 'lib/chef_fixie/authz_mapper.rb', line 62 def initialize # name of object map @names ||= {} @by_type ||= { :actor => {}, :container => {}, :group => {}, :object => {} } # maps class to a pre-created instance for efficiency @instance ||= {} end |
Instance Attribute Details
#by_type ⇒ Object (readonly)
Returns the value of attribute by_type.
60 61 62 |
# File 'lib/chef_fixie/authz_mapper.rb', line 60 def by_type @by_type end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
60 61 62 |
# File 'lib/chef_fixie/authz_mapper.rb', line 60 def instance @instance end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
60 61 62 |
# File 'lib/chef_fixie/authz_mapper.rb', line 60 def names @names end |
Instance Method Details
#authz_to_name(authz_id, ctype = nil) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/chef_fixie/authz_mapper.rb', line 83 def authz_to_name(authz_id, ctype = nil) types = if ctype.nil? AuthzUtils::TYPES else [ctype] end types.each do |type| by_type[type].each_pair do |name, klass| result = class_cache(klass).authz_to_name(authz_id) return result if result != :unknown end end :unknown end |
#class_cache(klass) ⇒ Object
70 71 72 |
# File 'lib/chef_fixie/authz_mapper.rb', line 70 def class_cache(klass) instance[klass] ||= klass.new end |
#dump ⇒ Object
79 80 81 |
# File 'lib/chef_fixie/authz_mapper.rb', line 79 def dump pp names end |
#register(klass, name, type) ⇒ Object
74 75 76 77 |
# File 'lib/chef_fixie/authz_mapper.rb', line 74 def register(klass, name, type) names[name] = klass by_type[type][name] = klass end |