Module: Replay::Publisher::ClassMethods

Defined in:
lib/replay/publisher.rb

Instance Method Summary collapse

Instance Method Details

#apply(event_type, &block) ⇒ Object



57
58
59
60
# File 'lib/replay/publisher.rb', line 57

def apply(event_type, &block)
  method_name = apply_method_for(event_type)
  define_method method_name, block
end

#apply_method_for(klass) ⇒ Object



66
67
68
# File 'lib/replay/publisher.rb', line 66

def apply_method_for(klass)
  "handle_#{stringify_class(klass).gsub(".", "_")}"
end

#key(keysym) ⇒ Object



49
50
51
# File 'lib/replay/publisher.rb', line 49

def key(keysym)
  @primary_key_method = keysym
end

#key_attrObject



53
54
55
# File 'lib/replay/publisher.rb', line 53

def key_attr
  @primary_key_method
end

#stringify_class(klass) ⇒ Object



62
63
64
# File 'lib/replay/publisher.rb', line 62

def stringify_class(klass)
  Replay::Inflector.underscore(klass.to_s.dup)
end