Class: ActiveFile::Base
Instance Attribute Summary
#attributes
Class Method Summary
collapse
#[], #[]=, add_to_record_index, auto_assign_fields, base_class, #cache_key, compute_type, configuration_for_custom_finder, count, create, create!, data, data=, define_custom_find_all_method, define_custom_find_method, define_getter_method, define_interrogator_method, define_setter_method, #destroyed?, #eql?, #errors, field, field_names, fields, has_instance_method?, has_singleton_method?, #hash, #id, #id=, #initialize, insert, mark_clean, mark_dirty, #marked_for_destruction?, method_missing, #new_record?, next_id, #persisted?, pluralize_table_names, primary_key, #readonly?, record_index, reset_record_index, respond_to?, #save, the_meta_class, #to_param, transaction, #valid?, validate_field, validate_unique_id
Class Method Details
.all(options = {}) ⇒ Object
13
14
15
16
|
# File 'lib/active_file/base.rb', line 13
def all(options={})
reload unless data_loaded
super
end
|
.delete_all ⇒ Object
23
24
25
26
|
# File 'lib/active_file/base.rb', line 23
def delete_all
self.data_loaded = true
super
end
|
.extension ⇒ Object
53
54
55
|
# File 'lib/active_file/base.rb', line 53
def extension
raise "Override Me"
end
|
.find(*args) ⇒ Object
57
58
59
60
|
# File 'lib/active_file/base.rb', line 57
def find(*args)
reload unless data_loaded
return super
end
|
.find_by_id(*args) ⇒ Object
62
63
64
65
|
# File 'lib/active_file/base.rb', line 62
def find_by_id(*args)
reload unless data_loaded
return super
end
|
.full_path ⇒ Object
47
48
49
50
51
|
# File 'lib/active_file/base.rb', line 47
def full_path
actual_root_path = root_path || Dir.pwd
actual_filename = filename || name.tableize
File.join(actual_root_path, "#{actual_filename}.#{extension}")
end
|
.load_file ⇒ Object
43
44
45
|
# File 'lib/active_file/base.rb', line 43
def load_file
raise "Override Me"
end
|
.reload(force = false) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/active_file/base.rb', line 28
def reload(force = false)
return if !self.dirty && !force && self.data_loaded
self.data_loaded = true
self.data = load_file
mark_clean
end
|
.set_filename(name) ⇒ Object
35
36
37
|
# File 'lib/active_file/base.rb', line 35
def set_filename(name)
self.filename = name
end
|
.set_root_path(path) ⇒ Object
39
40
41
|
# File 'lib/active_file/base.rb', line 39
def set_root_path(path)
self.root_path = path
end
|
.where(options) ⇒ Object
18
19
20
21
|
# File 'lib/active_file/base.rb', line 18
def where(options)
reload unless data_loaded
super
end
|