class Caracal::Core::Models::RelationshipModel
This class encapsulates the logic needed to store and manipulate relationship data.
Constants
- TYPE_MAP
constants
Attributes
relationship_data[R]
relationship_id[R]
accessors
relationship_key[R]
relationship_target[R]
relationship_type[R]
Public Instance Methods
data(value)
click to toggle source
# File lib/caracal/core/models/relationship_model.rb, line 77 def data(value) @relationship_data = value.to_s end
formatted_id()
click to toggle source
formatted_target()
click to toggle source
# File lib/caracal/core/models/relationship_model.rb, line 47 def formatted_target if relationship_type == :image ext = relationship_target.to_s.split('.').last ext = ext.split('?').first "media/image#{ relationship_id }.#{ ext }" else relationship_target end end
formatted_type()
click to toggle source
# File lib/caracal/core/models/relationship_model.rb, line 57 def formatted_type TYPE_MAP.fetch(relationship_type) end
id(value)
click to toggle source
matches?(str)
click to toggle source
target(value)
click to toggle source
# File lib/caracal/core/models/relationship_model.rb, line 72 def target(value) @relationship_target = value.to_s @relationship_key = value.to_s.downcase end
target_mode?()
click to toggle source
# File lib/caracal/core/models/relationship_model.rb, line 88 def target_mode? relationship_type == :link end
type(value)
click to toggle source
# File lib/caracal/core/models/relationship_model.rb, line 68 def type(value) @relationship_type = value.to_s.downcase.to_sym end
Private Instance Methods
option_keys()
click to toggle source
# File lib/caracal/core/models/relationship_model.rb, line 106 def option_keys [:id, :type, :target, :data] end