Module: Dcr

Defined in:
lib/dcr.rb,
lib/dcr/history.rb,
lib/dcr/version.rb,
lib/dcr/instance_method_history.rb,
lib/dcr/singleton_method_history.rb

Defined Under Namespace

Classes: History, InstanceMethodHistory, SingletonMethodHistory

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.instance(klass, org_method_name = nil, &decorator) ⇒ Object



9
10
11
12
13
# File 'lib/dcr.rb', line 9

def instance klass, org_method_name=nil, &decorator
  org_method_name = parse_method_name(decorator) unless org_method_name
  hist = InstanceMethodHistory.of klass
  hist.commit org_method_name, &decorator
end

.list_instance(klass, method_name) ⇒ Object



26
27
28
29
# File 'lib/dcr.rb', line 26

def list_instance klass, method_name
  hist = InstanceMethodHistory.of klass
  hist.list method_name
end

.list_singleton(object, method_name) ⇒ Object



31
32
33
34
# File 'lib/dcr.rb', line 31

def list_singleton object, method_name
  hist = SingletonMethodHistory.of object
  hist.list method_name
end

.parse_method_name(a_lambda = nil, &block) ⇒ Object



21
22
23
24
# File 'lib/dcr.rb', line 21

def parse_method_name a_lambda=nil, &block
  a_lambda = block_given? ? block : a_lambda
  a_lambda.parameters[0][1]
end

.rollback_all_instance(klass, method_name) ⇒ Object



41
42
43
44
# File 'lib/dcr.rb', line 41

def rollback_all_instance klass, method_name
  hist = InstanceMethodHistory.of klass
  hist.rollback_all method_name
end

.rollback_all_singleton(object, method_name) ⇒ Object



51
52
53
54
# File 'lib/dcr.rb', line 51

def rollback_all_singleton object, method_name
  hist = SingletonMethodHistory.of object
  hist.rollback_all method_name
end

.rollback_instance(klass, method_name) ⇒ Object



36
37
38
39
# File 'lib/dcr.rb', line 36

def rollback_instance klass, method_name
  hist = InstanceMethodHistory.of klass
  hist.rollback method_name
end

.rollback_singleton(object, method_name) ⇒ Object



46
47
48
49
# File 'lib/dcr.rb', line 46

def rollback_singleton object, method_name
  hist = SingletonMethodHistory.of object
  hist.rollback method_name
end

.singleton(object, org_method_name = nil, &decorator) ⇒ Object



15
16
17
18
19
# File 'lib/dcr.rb', line 15

def singleton object, org_method_name=nil, &decorator
  org_method_name = parse_method_name(decorator) unless org_method_name
  hist = SingletonMethodHistory.of object
  hist.commit org_method_name, &decorator
end