Class: CompoundForm::Base
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- 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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/models/compound_form/base.rb', line 45 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 = Iqvoc::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
25 26 27 |
# File 'app/models/compound_form/base.rb', line 25 def self.deep_cloning_relations {self.name.to_relation_name => :compound_form_contents} end |
.edit_partial_name(obj) ⇒ Object
41 42 43 |
# File 'app/models/compound_form/base.rb', line 41 def self.edit_partial_name(obj) "partials/compound_form/edit_base" end |
.partial_name(obj) ⇒ Object
37 38 39 |
# File 'app/models/compound_form/base.rb', line 37 def self.partial_name(obj) "partials/compound_form/base" end |
.published ⇒ Object
17 18 19 |
# File 'app/models/compound_form/base.rb', line 17 def self.published includes(:domain).references(:labels).merge(Label::Base.published) end |
.referenced_by(label_class) ⇒ Object
21 22 23 |
# File 'app/models/compound_form/base.rb', line 21 def self.referenced_by(label_class) # To something with the label class end |
.view_section(obj) ⇒ Object
29 30 31 |
# File 'app/models/compound_form/base.rb', line 29 def self.view_section(obj) "compound_forms" end |
.view_section_sort_key(obj) ⇒ Object
33 34 35 |
# File 'app/models/compound_form/base.rb', line 33 def self.view_section_sort_key(obj) 100 end |
Instance Method Details
#build_rdf(document, subject) ⇒ Object
63 64 65 |
# File 'app/models/compound_form/base.rb', line 63 def build_rdf(document, subject) subject.send(rdf_namespace).send(rdf_predicate, compound_form_contents.map {|cfc| IqRdf::build_uri(cfc.label.origin) }) end |