Module: Potpourri::ActiveRecordExtension
- Defined in:
- lib/extensions/active_record/active_record_extension.rb
Defined Under Namespace
Modules: ClassMethods
Classes: MissingIdentifierField, RecordNotFound
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(mod) ⇒ Object
3
4
5
6
7
|
# File 'lib/extensions/active_record/active_record_extension.rb', line 3
def self.included(mod)
raise NotAReport unless mod.ancestors.include?(Report)
mod.extend ClassMethods
mod.include ActiveRecord::FieldHelpers
end
|
Instance Method Details
#can_create_new_records? ⇒ Boolean
16
17
18
|
# File 'lib/extensions/active_record/active_record_extension.rb', line 16
def can_create_new_records?
self.class.instance_variable_get '@can_create_new_records'
end
|
#can_update_existing_records? ⇒ Boolean
12
13
14
|
# File 'lib/extensions/active_record/active_record_extension.rb', line 12
def can_update_existing_records?
self.class.instance_variable_get '@can_update_existing_records'
end
|
#identifier_field ⇒ Object
20
21
22
|
# File 'lib/extensions/active_record/active_record_extension.rb', line 20
def identifier_field
fields.detect &:identifier?
end
|
#import ⇒ Object
24
25
26
27
|
# File 'lib/extensions/active_record/active_record_extension.rb', line 24
def import
resources = super
resources.each { |resource| resource.save! }
end
|