Class: Relation
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Relation
- Defined in:
- app/models/relation.rb
Direct Known Subclasses
Constant Summary collapse
- EXPORT_FIELDS =
%w{target_name target_icon target_unique source_role source_icon source_unique rel_group}
Instance Attribute Summary collapse
-
#link ⇒ Object
Returns the value of attribute link.
-
#link_errors ⇒ Object
Returns the value of attribute link_errors.
-
#side ⇒ Object
Returns the value of attribute side.
-
#start ⇒ Object
Returns the value of attribute start.
Instance Method Summary collapse
- #export ⇒ Object
-
#source_role ⇒ Object
FIXME: validate uniqueness of source_role and target_role in scope site_id FIXME: set kpath from class.
- #target_role ⇒ Object
Instance Attribute Details
#link ⇒ Object
Returns the value of attribute link.
6 7 8 |
# File 'app/models/relation.rb', line 6 def link @link end |
#link_errors ⇒ Object
Returns the value of attribute link_errors.
6 7 8 |
# File 'app/models/relation.rb', line 6 def link_errors @link_errors end |
#side ⇒ Object
Returns the value of attribute side.
6 7 8 |
# File 'app/models/relation.rb', line 6 def side @side end |
#start ⇒ Object
Returns the value of attribute start.
6 7 8 |
# File 'app/models/relation.rb', line 6 def start @start end |
Instance Method Details
#export ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/relation.rb', line 21 def export res = Zafu::OrderedHash.new EXPORT_FIELDS.each do |key| if key == 'target_name' res[key] = VirtualClass.find_by_kpath(self['target_kpath']).name else value = self[key] if !value.blank? res[key] = value end end end res end |
#source_role ⇒ Object
FIXME: validate uniqueness of source_role and target_role in scope site_id FIXME: set kpath from class
13 14 15 |
# File 'app/models/relation.rb', line 13 def source_role source_unique ? self[:source_role] : self[:source_role].pluralize end |
#target_role ⇒ Object
17 18 19 |
# File 'app/models/relation.rb', line 17 def target_role target_unique ? self[:target_role] : self[:target_role].pluralize end |