Module: Birdses::PagesHelper
- Defined in:
- app/helpers/birdses/pages_helper.rb
Instance Method Summary collapse
- #create_or_update? ⇒ Boolean
- #current?(page) ⇒ Boolean
- #edit? ⇒ Boolean
- #index? ⇒ Boolean
- #new? ⇒ Boolean
- #post_or_put? ⇒ Boolean
- #title(page) ⇒ Object
Instance Method Details
#create_or_update? ⇒ Boolean
15 16 17 18 19 20 21 |
# File 'app/helpers/birdses/pages_helper.rb', line 15 def create_or_update? if new? :create elsif edit? :update end end |
#current?(page) ⇒ Boolean
31 32 33 |
# File 'app/helpers/birdses/pages_helper.rb', line 31 def current?(page) current_page?(controller: 'pages', action: page) end |
#edit? ⇒ Boolean
11 12 13 |
# File 'app/helpers/birdses/pages_helper.rb', line 11 def edit? current?(:edit) end |
#index? ⇒ Boolean
3 4 5 |
# File 'app/helpers/birdses/pages_helper.rb', line 3 def index? current?(:index) || current_page?(root_url) end |
#new? ⇒ Boolean
7 8 9 |
# File 'app/helpers/birdses/pages_helper.rb', line 7 def new? current?(:new) end |
#post_or_put? ⇒ Boolean
23 24 25 26 27 28 29 |
# File 'app/helpers/birdses/pages_helper.rb', line 23 def post_or_put? if new? :post elsif edit? :put end end |
#title(page) ⇒ Object
35 36 37 38 39 |
# File 'app/helpers/birdses/pages_helper.rb', line 35 def title(page) doc = Nokogiri::HTML::fragment(page.formatted_data, 'UTF-8') h1 = doc.css("h1:first-child") raw("<h1>#{page.name}</h1>") if h1.empty? end |