Class: Marty::Posting
- Inherits:
-
Base
show all
- Defined in:
- app/models/marty/posting.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
get_final_attrs, make_hash, make_openstruct, mcfly_pt
joins, old_joins
Class Method Details
.do_create(posting_type, dt, comment) ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'app/models/marty/posting.rb', line 29
def self.do_create(posting_type, dt, )
raise "unknown posting type #{name}" unless posting_type
o = new
o.posting_type = posting_type
o. =
o.created_dt = dt
o.save!
o
end
|
.get_struct_attrs ⇒ Object
40
41
42
|
# File 'app/models/marty/posting.rb', line 40
def self.get_struct_attrs
self.struct_attrs ||= super + ['created_dt', 'name']
end
|
.make_name(posting_type, dt) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/models/marty/posting.rb', line 9
def self.make_name(posting_type, dt)
return 'NOW' if Mcfly.is_infinity(dt)
return unless posting_type
dt ||= Time.zone.now
"#{posting_type}-#{dt.strftime('%Y%m%d-%H%M')}"
end
|
Instance Method Details
#set_posting_name ⇒ Object
24
25
26
27
|
# File 'app/models/marty/posting.rb', line 24
def set_posting_name
self.name = self.class.make_name(posting_type, created_dt)
true
end
|