Module: Elabs::ApplicationHelper
- Defined in:
- app/helpers/elabs/application_helper.rb
Instance Method Summary collapse
- #model_from_entity(type) ⇒ Object
- #page_title(title, namespace = nil) ⇒ Object
- #random_string(length = 5) ⇒ Object
- #show_nsfw? ⇒ Boolean
- #singular_type_name(entity) ⇒ Object
-
#with_format(format) ⇒ Object
This method yields a block.
Instance Method Details
#model_from_entity(type) ⇒ Object
35 36 37 |
# File 'app/helpers/elabs/application_helper.rb', line 35 def model_from_entity(type) "Elabs::#{type.classify}".constantize end |
#page_title(title, namespace = nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/helpers/elabs/application_helper.rb', line 11 def page_title(title, namespace = nil) out = [Elabs.site_name] out.push(namespace) if namespace out.push(title) if title out.join('::') end |
#random_string(length = 5) ⇒ Object
3 4 5 |
# File 'app/helpers/elabs/application_helper.rb', line 3 def random_string(length = 5) [*('a'..'z'), *('0'..'9')].shuffle[0, length].join end |
#show_nsfw? ⇒ Boolean
7 8 9 |
# File 'app/helpers/elabs/application_helper.rb', line 7 def show_nsfw? session[:show_nsfw] end |
#singular_type_name(entity) ⇒ Object
31 32 33 |
# File 'app/helpers/elabs/application_helper.rb', line 31 def singular_type_name(entity) entity.class.name.demodulize.tableize.singularize end |
#with_format(format) ⇒ Object
This method yields a block.
21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/elabs/application_helper.rb', line 21 def with_format(format) old_formats = formats begin self.formats = [format] return yield ensure self.formats = old_formats end end |