Module: EnoughFields
- Defined in:
- lib/enough_fields.rb,
lib/enough_fields/rack.rb,
lib/enough_fields/version.rb,
lib/enough_fields/monit_set.rb,
lib/enough_fields/attributes.rb,
lib/enough_fields/notification.rb,
lib/enough_fields/attribute_value.rb
Defined Under Namespace
Classes: AttributeValue, Attributes, EnoughFieldsRailtie, MonitSet, Notification, Rack, Result
Constant Summary
collapse
- VERSION =
"0.0.3"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.disable_browser_cache ⇒ Object
Returns the value of attribute disable_browser_cache.
19
20
21
|
# File 'lib/enough_fields.rb', line 19
def disable_browser_cache
@disable_browser_cache
end
|
Class Method Details
.add_notification(call_stack, klass, fields) ⇒ Object
73
74
75
76
|
# File 'lib/enough_fields.rb', line 73
def add_notification(call_stack, klass, fields)
notification = Notification.new(call_stack, klass, fields)
notifications << notification
end
|
.enable=(enable) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/enough_fields.rb', line 22
def enable=(enable)
@enable = enable
if enable?
Mongoid::Cursor.class_eval do
alias_method :origin_each, :each
def each
@cursor.each do |document|
attributes = Attributes.build(@klass, document)
yield Mongoid::Factory.build(@klass, attributes)
end
end
end
Mongoid::Factory.class_eval do
class <<self
def build(klass, attributes)
type = attributes["_type"]
type ? type.constantize.instantiate(attributes) : klass.instantiate(attributes)
end
end
end
end
end
|
.enable? ⇒ Boolean
47
48
49
|
# File 'lib/enough_fields.rb', line 47
def enable?
@enable == true
end
|
.end_request ⇒ Object
63
64
65
66
|
# File 'lib/enough_fields.rb', line 63
def end_request
Thread.current[:monit_set] = nil
@notifications = nil
end
|
.enough_fields_logger=(active) ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/enough_fields.rb', line 51
def enough_fields_logger=(active)
if active
enough_fields_log_file = File.open( 'log/enough_fields.log', 'a+' )
enough_fields_log_file.sync
UniformNotifier.customized_logger = enough_fields_log_file
end
end
|
.gather_inline_notifications ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/enough_fields.rb', line 78
def gather_inline_notifications
responses = []
for_each_active_notifier_with_notification do |notification|
responses << notification.notify_inline
end
responses.join( "\n" )
end
|
.notification? ⇒ Boolean
68
69
70
71
|
# File 'lib/enough_fields.rb', line 68
def notification?
current_monit_set.check_notifications
!notifications.empty?
end
|
86
87
88
89
90
|
# File 'lib/enough_fields.rb', line 86
def perform_out_of_channel_notifications
for_each_active_notifier_with_notification do |notification|
notification.notify_out_of_channel
end
end
|
.start_request ⇒ Object
59
60
61
|
# File 'lib/enough_fields.rb', line 59
def start_request
Thread.current[:monit_set] = MonitSet.new
end
|