Class: Timingapp::TimingRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Timingapp::TimingRecord
show all
- Defined in:
- lib/timingapp/timing_record.rb
Direct Known Subclasses
AppActivity, AppActivityWithStrings, Application, Device, Event, EventSource, EventSourceTaskActivity, Filter, Integration, IntegrationLogResult, IntegrationProject, Path, Project, SchemaMigration, TaskActivity, Title
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.has_parent(foreign_key = :parentID) ⇒ Object
15
16
17
|
# File 'lib/timingapp/timing_record.rb', line 15
def self.has_parent(foreign_key = :parentID)
belongs_to :parent, foreign_key: foreign_key, class_name: name
end
|
.json_column(column) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/timingapp/timing_record.rb', line 19
def self.json_column(column)
define_method(column) do |*args, &block|
value = super(*args, &block)
begin
JSON.parse(value)
rescue JSON::ParserError, TypeError
value
end
end
end
|
.readonly? ⇒ Boolean
7
8
9
|
# File 'lib/timingapp/timing_record.rb', line 7
def self.readonly?
true
end
|
.time_column(column) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/timingapp/timing_record.rb', line 31
def self.time_column(column)
define_method(column) do |*args, &block|
value = super(*args, &block)
begin
Time.at(value)
rescue TypeError
value
end
end
end
|
Instance Method Details
#before_destroy ⇒ Object
11
12
13
|
# File 'lib/timingapp/timing_record.rb', line 11
def before_destroy
raise ActiveRecord::ReadOnlyRecord, "Cannot delete a read-only record"
end
|