Class: Docs::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Docs::Page
- Defined in:
- app/models/docs/page.rb
Instance Method Summary collapse
- #anchor ⇒ Object
- #method_path ⇒ Object
- #only_path ⇒ Object
- #only_query ⇒ Object
- #page_category_slug ⇒ Object
- #page_category_slug=(slug) ⇒ Object
- #set_body_with_default_table ⇒ Object
- #splitted_path ⇒ Object
- #weight ⇒ Object
Instance Method Details
#anchor ⇒ Object
32 33 34 |
# File 'app/models/docs/page.rb', line 32 def anchor @anchor ||= method_path.downcase.gsub(/[^\w]/, "_") end |
#method_path ⇒ Object
16 17 18 |
# File 'app/models/docs/page.rb', line 16 def method_path @method_path ||= [via, only_path].join(" ") end |
#only_path ⇒ Object
36 37 38 |
# File 'app/models/docs/page.rb', line 36 def only_path @only_path ||= path.split("?").first end |
#only_query ⇒ Object
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_slug ⇒ Object
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_table ⇒ Object
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_path ⇒ Object
44 45 46 |
# File 'app/models/docs/page.rb', line 44 def splitted_path @splitted_path ||= path.split('?') end |
#weight ⇒ Object
12 13 14 |
# File 'app/models/docs/page.rb', line 12 def weight super.to_i end |