Class: CompoundForm::Base
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- CompoundForm::Base
- Defined in:
- app/models/compound_form/base.rb
Class Method Summary collapse
- .build_from_rdf(rdf_subject, rdf_predicate, rdf_object) ⇒ Object
- .deep_cloning_relations ⇒ Object
- .edit_partial_name(obj) ⇒ Object
- .partial_name(obj) ⇒ Object
- .published ⇒ Object
- .referenced_by(label_class) ⇒ Object
- .view_section(obj) ⇒ Object
- .view_section_sort_key(obj) ⇒ Object
Instance Method Summary collapse
Class Method Details
.build_from_rdf(rdf_subject, rdf_predicate, rdf_object) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/compound_form/base.rb', line 46 def self.build_from_rdf(rdf_subject, rdf_predicate, rdf_object) unless rdf_subject.is_a? Label::SKOSXL::Base raise "#{self.name}#build_from_rdf: Subject (#{rdf_subject}) must be a 'Label::SKOSXL::Base'" end target_class = RDFAPI::PREDICATE_DICTIONARY[rdf_predicate] || self ActiveRecord::Base.transaction do begin compound_form = target_class.create(domain: rdf_subject) # create compound form create_compound_form_contents(rdf_object, compound_form) rescue Exception => e raise ActiveRecord::Rollback, e end end end |
.deep_cloning_relations ⇒ Object
26 27 28 |
# File 'app/models/compound_form/base.rb', line 26 def self.deep_cloning_relations {self.name.to_relation_name => :compound_form_contents} end |
.edit_partial_name(obj) ⇒ Object
42 43 44 |
# File 'app/models/compound_form/base.rb', line 42 def self.edit_partial_name(obj) "partials/compound_form/edit_base" end |
.partial_name(obj) ⇒ Object
38 39 40 |
# File 'app/models/compound_form/base.rb', line 38 def self.partial_name(obj) "partials/compound_form/base" end |
.published ⇒ Object
18 19 20 |
# File 'app/models/compound_form/base.rb', line 18 def self.published includes(:domain).references(:labels).merge(Label::Base.published) end |
.referenced_by(label_class) ⇒ Object
22 23 24 |
# File 'app/models/compound_form/base.rb', line 22 def self.referenced_by(label_class) # To something with the label class end |
.view_section(obj) ⇒ Object
30 31 32 |
# File 'app/models/compound_form/base.rb', line 30 def self.view_section(obj) "compound_forms" end |
.view_section_sort_key(obj) ⇒ Object
34 35 36 |
# File 'app/models/compound_form/base.rb', line 34 def self.view_section_sort_key(obj) 100 end |
Instance Method Details
#build_rdf(document, subject) ⇒ Object
64 65 66 67 68 |
# File 'app/models/compound_form/base.rb', line 64 def build_rdf(document, subject) if compound_form_contents.any? subject.send(rdf_namespace).send(rdf_predicate, compound_form_contents.map {|cfc| IqRdf::build_uri(cfc.label.origin) }) end end |