Class: ActiveFedora::AttributeMethods::AttributeMethodCache
- Inherits:
-
Object
- Object
- ActiveFedora::AttributeMethods::AttributeMethodCache
- Defined in:
- lib/active_fedora/attribute_methods.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize ⇒ AttributeMethodCache
constructor
A new instance of AttributeMethodCache.
Constructor Details
#initialize ⇒ AttributeMethodCache
Returns a new instance of AttributeMethodCache.
19 20 21 22 |
# File 'lib/active_fedora/attribute_methods.rb', line 19 def initialize @module = Module.new @method_cache = ThreadSafe::Cache.new end |
Instance Method Details
#[](name) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/active_fedora/attribute_methods.rb', line 24 def [](name) @method_cache.compute_if_absent(name) do safe_name = name.unpack('h*').first temp_method = "__temp__#{safe_name}" ActiveFedora::AttributeMethods::AttrNames.set_name_cache safe_name, name @module.module_eval method_body(temp_method, safe_name), __FILE__, __LINE__ @module.instance_method temp_method end end |