Module: ReactiveTags

Included in:
Array, Model, ReactiveArray, String, URL
Defined in:
lib/volt/reactive/reactive_tags.rb

Overview

ReactiveTags provide an easy way to specify how a class deals with reactive events and method calls.als

Defined Under Namespace

Modules: ClassMethods Classes: MethodTagger, MethodTags

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



60
61
62
63
# File 'lib/volt/reactive/reactive_tags.rb', line 60

def self.included(base)
  base.send(:extend, ClassMethods)
  base.send(:include, Events)
end

Instance Method Details

#reactive_method_tag(method_name, tag_name, klass = self.class) ⇒ Object

Returns a reference to the tags on a method



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/volt/reactive/reactive_tags.rb', line 45

def reactive_method_tag(method_name, tag_name, klass=self.class)
  # Check to make sure we haven't gone above a class that has included
  # ReactiveTags
  return nil if !klass || !klass.method_defined?(:reactive_method_tag)
  
  tags = klass.instance_variable_get('@reactive_method_tags')

  if tags && (tag = tags[method_name.to_sym]) && (tag = tag.send(tag_name))
    return tag
  end
  
  return self.reactive_method_tag(method_name, tag_name, klass.superclass)
end