Class: Texter::Text

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/texter/text.rb

Constant Summary collapse

BLOCK =
'block'
TAG_TYPES =
[BLOCK, 'inline']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tag_typeObject



25
26
27
# File 'app/models/texter/text.rb', line 25

def tag_type
  TAG_TYPES.include?(@tag_type.to_s) ? @tag_type : BLOCK
end

Class Method Details

.find_or_create_from_translations_by_path(path) ⇒ Object



11
12
13
14
15
# File 'app/models/texter/text.rb', line 11

def self.find_or_create_from_translations_by_path(path)
  text = find_or_initialize_by_path(path)
  text.new_record? && text.update_attributes(text.default_attributes)
  text
end

Instance Method Details

#default_attributesObject



29
30
31
# File 'app/models/texter/text.rb', line 29

def default_attributes
  { :body => get_body }
end

#get_body(options = {}) ⇒ Object



21
22
23
# File 'app/models/texter/text.rb', line 21

def get_body(options = {})
  persisted? ? body : Texter.translate(path, options)
end

#to_paramObject



17
18
19
# File 'app/models/texter/text.rb', line 17

def to_param
  path
end