Class: Inform::Link
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Inform::Link
- Defined in:
- lib/runtime/link.rb
Overview
The Inform::Link class
Constant Summary collapse
- LinkTemplate =
'%<link_name>s -> %<to_name>s [%<to_identity>s]'.freeze
- LinkMethods =
%w[from_id to_id].freeze
- MethodWriterTemplate =
'%<method_name>s='.freeze
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #after_save ⇒ Object
- #before_create ⇒ Object
- #init_with(coder) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Sequel::Model
Methods included from InheritanceListener
Instance Method Details
#<=>(other) ⇒ Object
80 81 82 |
# File 'lib/runtime/link.rb', line 80 def <=>(other) self.name <=> other.name end |
#after_save ⇒ Object
71 72 73 74 |
# File 'lib/runtime/link.rb', line 71 def after_save super self.modified_at = Time.now.utc end |
#before_create ⇒ Object
66 67 68 69 |
# File 'lib/runtime/link.rb', line 66 def before_create self.created_at ||= Time.now super end |
#init_with(coder) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/runtime/link.rb', line 84 def init_with(coder) LinkMethods.each do |method_name| method_symbol = format(MethodWriterTemplate, method_name: method_name).to_sym self.send(method_symbol, coder[method_name]) if self.respond_to? method_symbol end self end |
#to_s ⇒ Object
76 77 78 |
# File 'lib/runtime/link.rb', line 76 def to_s format(LinkTemplate, link_name: name, to_name: to.name, to_identity: to.identity) end |