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
Constant Summary
collapse
- VERSION =
"0.0.1"
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
76
77
78
79
|
# File 'lib/enough_fields.rb', line 76
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
46
47
48
49
|
# 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
if @cursor.count > 1
@cursor.each do |document|
attributes = Attributes.build(@klass, document)
yield Mongoid::Factory.build(@klass, attributes)
end
else
:origin_each
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
51
52
53
|
# File 'lib/enough_fields.rb', line 51
def enable?
@enable == true
end
|
.end_request ⇒ Object
67
68
69
|
# File 'lib/enough_fields.rb', line 67
def end_request
Thread.current[:monit_set] = nil
end
|
.enough_fields_logger=(active) ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/enough_fields.rb', line 55
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
81
82
83
84
85
86
87
|
# File 'lib/enough_fields.rb', line 81
def gather_inline_notifications
responses = []
for_each_active_notifier_with_notification do |notification|
responses << notification.notify_inline
end
responses.join( "\n" )
end
|
.notification? ⇒ Boolean
71
72
73
74
|
# File 'lib/enough_fields.rb', line 71
def notification?
current_monit_set.check_notifications
!notifications.empty?
end
|
89
90
91
92
93
|
# File 'lib/enough_fields.rb', line 89
def perform_out_of_channel_notifications
for_each_active_notifier_with_notification do |notification|
notification.notify_out_of_channel
end
end
|
.start_request ⇒ Object
63
64
65
|
# File 'lib/enough_fields.rb', line 63
def start_request
Thread.current[:monit_set] = MonitSet.new
end
|