Class: Language

Inherits:
ApplicationRecord show all
Includes:
Mumuki::Domain::Syncable, WithCaseInsensitiveSearch
Defined in:
app/models/language.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mumuki::Domain::Syncable

#platform_class_name

Methods inherited from ApplicationRecord

aggregate_of, all_except, defaults, #delete, #destroy!, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, #update_and_notify!, update_or_create!, whitelist_attributes

Class Method Details

.for_name(name) ⇒ Object



58
59
60
# File 'app/models/language.rb', line 58

def self.for_name(name)
  find_by_ignore_case!(:name, name) if name
end

Instance Method Details

#assets_urls_for(kind, content_type) ⇒ Object



80
81
82
# File 'app/models/language.rb', line 80

def assets_urls_for(kind, content_type)
  send "#{kind}_#{content_type}_urls"
end

#bridgeObject



42
43
44
# File 'app/models/language.rb', line 42

def bridge
  Mumukit::Bridge::Runner.new(runner_url)
end

#deviconObject



62
63
64
# File 'app/models/language.rb', line 62

def devicon
  self[:devicon] || name.downcase
end

#directives_sectionsObject



75
76
77
# File 'app/models/language.rb', line 75

def directives_sections
  new_directive Mumukit::Directives::Sections
end

#highlight_modeObject



46
47
48
# File 'app/models/language.rb', line 46

def highlight_mode
  self[:highlight_mode] || name
end

#import_from_resource_h!(resource_h) ⇒ Object



70
71
72
73
# File 'app/models/language.rb', line 70

def import_from_resource_h!(resource_h)
  assign_attributes resource_h.except(:runner_url)
  save!
end

#interpolate_references_for(assignment, field) ⇒ Object

TODO this should be a Mumukit::Directives::Directive and be part of a pipeline



86
87
88
# File 'app/models/language.rb', line 86

def interpolate_references_for(assignment, field)
  interpolate(field, assignment.submitter.interpolations, lambda { |content| replace_content_reference(assignment, content) })
end

#output_content_typeObject



50
51
52
# File 'app/models/language.rb', line 50

def output_content_type
  Mumukit::ContentType.for(self[:output_content_type])
end

#sync_keyObject



66
67
68
# File 'app/models/language.rb', line 66

def sync_key
  Mumukit::Sync.key :language, runner_url
end

#to_embedded_resource_hObject



90
91
92
# File 'app/models/language.rb', line 90

def to_embedded_resource_h
  as_json(only: [:name, :extension, :test_extension]).symbolize_keys
end

#to_sObject



54
55
56
# File 'app/models/language.rb', line 54

def to_s
  name
end