Class: CheckIn::Writer::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/check_in/writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ Configuration

Returns a new instance of Configuration.



17
18
19
# File 'lib/check_in/writer.rb', line 17

def initialize(base)
  @base = base
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



15
16
17
# File 'lib/check_in/writer.rb', line 15

def base
  @base
end

Instance Method Details

#check_in_after(method_name) ⇒ Object

redefine method to call check_in after original method is called



46
47
48
49
50
51
52
53
54
# File 'lib/check_in/writer.rb', line 46

def check_in_after(method_name)
  base.class_eval <<-END
    alias_method :pre_check_in_#{method_name}, :#{method_name}
    def #{method_name}(*args)
      pre_check_in_#{method_name}(*args)
      check_in(*args)
    end
  END
end

#check_in_before(method_name) ⇒ Object

redefine method to call check_in before original method is called



57
58
59
60
61
62
63
64
65
# File 'lib/check_in/writer.rb', line 57

def check_in_before(method_name)
  base.class_eval <<-END
    alias_method :pre_check_in_#{method_name}, :#{method_name}
    def #{method_name}(*args)
      check_in(*args)
      pre_check_in_#{method_name}(*args)
    end
  END
end

#instance_name_methodObject



41
42
43
# File 'lib/check_in/writer.rb', line 41

def instance_name_method
  @instance_name_method ||= :to_s
end

#instance_name_method=(instance_name_method) ⇒ Object



37
38
39
# File 'lib/check_in/writer.rb', line 37

def instance_name_method=(instance_name_method) 
  @instance_name_method = instance_name_method
end

#list_lengthObject



33
34
35
# File 'lib/check_in/writer.rb', line 33

def list_length
  @list_length || 500
end

#list_length=(list_length) ⇒ Object



29
30
31
# File 'lib/check_in/writer.rb', line 29

def list_length=(list_length)
  @list_length = list_length
end

#redis_keyObject



67
68
69
# File 'lib/check_in/writer.rb', line 67

def redis_key
  "checkins:#{service_name}"
end

#service_nameObject



25
26
27
# File 'lib/check_in/writer.rb', line 25

def service_name
  @service_name ||= base.name
end

#service_name=(service_name) ⇒ Object



21
22
23
# File 'lib/check_in/writer.rb', line 21

def service_name=(service_name)
  @service_name = service_name
end

#setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



71
72
73
# File 'lib/check_in/writer.rb', line 71

def setup(&block)
  yield self
end