Class: Eventbox::ObjectRegistry
- Inherits:
-
Object
- Object
- Eventbox::ObjectRegistry
- Defined in:
- lib/eventbox/object_registry.rb
Class Method Summary collapse
Class Method Details
.get_tag(object) ⇒ Object
30 31 32 |
# File 'lib/eventbox/object_registry.rb', line 30 def get_tag(object) object.instance_variable_defined?(:@__event_box_tag__) && object.instance_variable_get(:@__event_box_tag__) end |
.set_tag(object, new_tag) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/eventbox/object_registry.rb', line 20 def set_tag(object, new_tag) raise InvalidAccess, "object is not taggable: #{object.inspect}" unless taggable?(object) tag = get_tag(object) if tag && tag != new_tag raise InvalidAccess, "object #{object.inspect} is already tagged to #{tag.inspect}" end object.instance_variable_set(:@__event_box_tag__, new_tag) end |
.taggable?(object) ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/eventbox/object_registry.rb', line 6 def taggable?(object) case object # Keep the list of non taggable object types in sync with Sanitizer.sanitize_value when NilClass, Numeric, Symbol, TrueClass, FalseClass, WrappedObject, Action, Module, Eventbox, Proc false else if object.frozen? false else true end end end |