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

active_between, aggregate_of, all_except, defaults, #delete, #destroy!, enum_prefixed_translations_for, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, teaser_on, #update_and_notify!, update_or_create!, whitelist_attributes, with_pg_retry, with_temporary_token

Methods included from WithPgLock

#with_pg_lock

Class Method Details

.for_name(name) ⇒ Object



60
61
62
# File 'app/models/language.rb', line 60

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

Instance Method Details

#assets_urls_for(kind, content_type) ⇒ Object



82
83
84
# File 'app/models/language.rb', line 82

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

#bridgeObject



44
45
46
# File 'app/models/language.rb', line 44

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

#deviconObject



64
65
66
# File 'app/models/language.rb', line 64

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

#directives_sectionsObject



77
78
79
# File 'app/models/language.rb', line 77

def directives_sections
  new_directive Mumukit::Directives::Sections
end

#highlight_modeObject



48
49
50
# File 'app/models/language.rb', line 48

def highlight_mode
  self[:highlight_mode] || name
end

#import_from_resource_h!(resource_h) ⇒ Object



72
73
74
75
# File 'app/models/language.rb', line 72

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



88
89
90
# File 'app/models/language.rb', line 88

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

#output_content_typeObject



52
53
54
# File 'app/models/language.rb', line 52

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

#sync_keyObject



68
69
70
# File 'app/models/language.rb', line 68

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

#to_embedded_resource_hObject



92
93
94
# File 'app/models/language.rb', line 92

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

#to_sObject



56
57
58
# File 'app/models/language.rb', line 56

def to_s
  name
end