Class: Docs::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/docs/page.rb

Instance Method Summary collapse

Instance Method Details

#anchorObject



32
33
34
# File 'app/models/docs/page.rb', line 32

def anchor
  @anchor ||= method_path.downcase.gsub(/[^\w]/, "_")
end

#method_pathObject



16
17
18
# File 'app/models/docs/page.rb', line 16

def method_path
  @method_path ||= [via, only_path].join(" ")
end

#only_pathObject



36
37
38
# File 'app/models/docs/page.rb', line 36

def only_path
  @only_path ||= path.split("?").first
end

#only_queryObject



40
41
42
# File 'app/models/docs/page.rb', line 40

def only_query
  @only_query ||= splitted_path.length > 1 ? "?#{splitted_path.last}" : ""
end

#page_category_slugObject



20
21
22
# File 'app/models/docs/page.rb', line 20

def page_category_slug
  @page_category_slug ||= page_category.try(:slug)
end

#page_category_slug=(slug) ⇒ Object



24
25
26
27
28
29
30
# File 'app/models/docs/page.rb', line 24

def page_category_slug=(slug)
  @page_category_slug = begin
    slug = slug.to_s.downcase.underscore
    self.page_category = PageCategory.find_or_initialize_by(slug: slug)
    page_category.try(:slug)
  end
end

#set_body_with_default_tableObject



48
49
50
51
52
53
54
55
56
57
# File 'app/models/docs/page.rb', line 48

def set_body_with_default_table
  return body if body.present?
  self.body = <<-markdown.gsub(/^\s+\.|/, '')
    .| Параметр | Описание |
    .|----------|----------|
    .|          |          |
    .
    .
  markdown
end

#splitted_pathObject



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

def splitted_path
  @splitted_path ||= path.split('?')
end

#weightObject



12
13
14
# File 'app/models/docs/page.rb', line 12

def weight
  super.to_i
end