Module: Canis::FieldHistory

Defined in:
lib/canis/core/include/rhistory.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(obj) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/canis/core/include/rhistory.rb', line 23

def self.extended(obj)

  obj.instance_exec {
    @history ||= []
    $history_key ||= ?\M-h
    # ensure that the field is not overriding this in handle_key
    bind_key($history_key) { _show_history }
    # widget should have CHANGED event, or this will either give error, or just not work
    # else please update history whenever you want a value to be retrieved
    bind(:CHANGED) { @history << @text if @text && (!@history.include? @text) }
  }
end

Instance Method Details

#history(arr) ⇒ Object

pass the array of history values Trying out a change where an item can also be sent in. I am lost, i want the initialization to happen once.



39
40
41
42
43
44
45
46
# File 'lib/canis/core/include/rhistory.rb', line 39

def history arr
  return @history unless arr
  if arr.is_a? Array
    @history = arr 
  else
    @history << arr unless @history.include? arr
  end
end

#history=(x) ⇒ Object



47
# File 'lib/canis/core/include/rhistory.rb', line 47

def history=(x); history(x); end

#history_config(config = {}) ⇒ Object

pass in some configuration for histroy such as row and column to show popup on



50
51
52
# File 'lib/canis/core/include/rhistory.rb', line 50

def history_config config={}
  @_history_config = config
end