Class: Concept::Relation::Base

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/concept/relation/base.rb

Overview

Copyright 2011 innoQ Deutschland GmbH

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Direct Known Subclasses

SKOS::Base

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.by_owner(owner_id) ⇒ Object

********* Scopes



44
45
46
# File 'app/models/concept/relation/base.rb', line 44

def self.by_owner(owner_id)
  where(:owner_id => owner_id)
end

.by_owner_origin(owner_origin) ⇒ Object



48
49
50
# File 'app/models/concept/relation/base.rb', line 48

def self.by_owner_origin(owner_origin)
  includes(:owner).merge(Concept::Base.by_origin(owner_origin))
end

.by_target_origin(target_origin) ⇒ Object



52
53
54
# File 'app/models/concept/relation/base.rb', line 52

def self.by_target_origin(target_origin)
  includes(:target).merge(Concept::Base.by_origin(target_origin))
end

.edit_partial_name(obj) ⇒ Object



86
87
88
# File 'app/models/concept/relation/base.rb', line 86

def self.edit_partial_name(obj)
  "partials/concept/relation/edit_base"
end

.partial_name(obj) ⇒ Object



82
83
84
# File 'app/models/concept/relation/base.rb', line 82

def self.partial_name(obj)
  "partials/concept/relation/base"
end

.publishedObject



60
61
62
# File 'app/models/concept/relation/base.rb', line 60

def self.published
  includes(:target).merge(Concept::Base.published)
end

.rankable?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'app/models/concept/relation/base.rb', line 111

def self.rankable?
  self.class.included_modules.include?(Iqvoc::Rankable)
end

.reverse_relation_classObject

********* Methods



70
71
72
# File 'app/models/concept/relation/base.rb', line 70

def self.reverse_relation_class
  self
end

.singular?Boolean

if ‘singular` is true, only a single occurrence is allowed per instance

Returns:

  • (Boolean)


91
92
93
# File 'app/models/concept/relation/base.rb', line 91

def self.singular?
  false
end

.target_editor_selectableObject



56
57
58
# File 'app/models/concept/relation/base.rb', line 56

def self.target_editor_selectable
  includes(:target).merge(Concept::Base.editor_selectable)
end

.target_in_edit_modeObject



64
65
66
# File 'app/models/concept/relation/base.rb', line 64

def self.target_in_edit_mode
  joins(:target).merge(Concept::Base.in_edit_mode)
end

.view_section(obj) ⇒ Object



74
75
76
# File 'app/models/concept/relation/base.rb', line 74

def self.view_section(obj)
  "relations"
end

.view_section_sort_key(obj) ⇒ Object



78
79
80
# File 'app/models/concept/relation/base.rb', line 78

def self.view_section_sort_key(obj)
  100
end

Instance Method Details

#rankObject



95
96
97
98
99
100
101
# File 'app/models/concept/relation/base.rb', line 95

def rank
  unless self.class.rankable?
    raise "Use `include Rankable` to make a concept relation rankable."
  else
    super
  end
end

#rank=(val) ⇒ Object



103
104
105
106
107
108
109
# File 'app/models/concept/relation/base.rb', line 103

def rank=(val)
  unless self.class.rankable?
    raise "Use `include Rankable` to make a concept relation rankable."
  else
    super
  end
end