action_tracker_config.rb
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class ActionTrackerConfig
def self.config
@action_tracker_config ||= {}
end
def self.config=(h)
@action_tracker_config = h
end
def self.verbs
config[:verbs] || {}
end
def self.verbs=(h)
config[:verbs] = h
end
def self.verb_names
verbs.keys.map(&:to_s)
end
def self.current_user
config[:current_user] || proc{ nil }
end
def self.current_user= block
config[:current_user] = block
end
def self.default_filter_time
config[:default_filter_time] || :after
end
def self.default_filter_time=(before_or_after)
config[:default_filter_time] = before_or_after
end
def self.timeout
config[:timeout] || 5.minutes
end
def self.timeout=(seconds)
config[:timeout] = seconds
end
def self.get_verb(verb)
verbs[verb.to_s] || verbs[verb.to_sym] || {}
end
def self.verb_type(verb)
type = get_verb(verb.to_s)[:type] || get_verb(verb.to_s)['type'] || :single
verb_types.include?(type.to_sym) ? type : :single
end
def self.verb_types
[:single, :updatable, :groupable]
end
end