Class: Revelry::Content::Configuration
- Inherits:
-
Object
- Object
- Revelry::Content::Configuration
- Defined in:
- lib/revelry/content/configuration.rb
Instance Method Summary collapse
- #authorization_policy(&block) ⇒ Object
- #authorize(controller) ⇒ Object
- #default_authorization_policy ⇒ Object
- #default_markdown_renderer ⇒ Object
- #default_sanitizer ⇒ Object
- #default_user_finder ⇒ Object
- #js_export ⇒ Object
- #js_export=(v) ⇒ Object
- #js_export? ⇒ Boolean
- #markdown_renderer ⇒ Object
- #markdown_renderer=(klass) ⇒ Object
- #sanitizer ⇒ Object
- #sanitizer=(klass) ⇒ Object
- #user_for_content(&block) ⇒ Object
Instance Method Details
#authorization_policy(&block) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/revelry/content/configuration.rb', line 26 def (&block) if block_given? = block end || end |
#authorize(controller) ⇒ Object
46 47 48 49 |
# File 'lib/revelry/content/configuration.rb', line 46 def (controller) user = user_for_content.call(controller) .call(user) end |
#default_authorization_policy ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/revelry/content/configuration.rb', line 33 def ->(user) do if user.present? if user.respond_to?(:has_role?) return user.has_role? :admin else return user.admin? end end false end end |
#default_markdown_renderer ⇒ Object
59 60 61 |
# File 'lib/revelry/content/configuration.rb', line 59 def default_markdown_renderer Redcarpet::Render::HTML end |
#default_sanitizer ⇒ Object
71 72 73 |
# File 'lib/revelry/content/configuration.rb', line 71 def default_sanitizer ->(rendered_content) { Sanitize.fragment(rendered_content, Sanitize::Config::BASIC.merge(remove_contents: true)) } end |
#default_user_finder ⇒ Object
22 23 24 |
# File 'lib/revelry/content/configuration.rb', line 22 def default_user_finder ->(controller) { controller.current_user } end |
#js_export ⇒ Object
2 3 4 |
# File 'lib/revelry/content/configuration.rb', line 2 def js_export @js_export || false end |
#js_export=(v) ⇒ Object
10 11 12 |
# File 'lib/revelry/content/configuration.rb', line 10 def js_export=(v) @js_export = v end |
#js_export? ⇒ Boolean
6 7 8 |
# File 'lib/revelry/content/configuration.rb', line 6 def js_export? js_export end |
#markdown_renderer ⇒ Object
51 52 53 |
# File 'lib/revelry/content/configuration.rb', line 51 def markdown_renderer @markdown_renderer || default_markdown_renderer end |
#markdown_renderer=(klass) ⇒ Object
55 56 57 |
# File 'lib/revelry/content/configuration.rb', line 55 def markdown_renderer=(klass) @markdown_renderer = klass end |
#sanitizer ⇒ Object
67 68 69 |
# File 'lib/revelry/content/configuration.rb', line 67 def sanitizer @sanitizer || default_sanitizer end |
#sanitizer=(klass) ⇒ Object
63 64 65 |
# File 'lib/revelry/content/configuration.rb', line 63 def sanitizer=(klass) @sanitizer = klass end |
#user_for_content(&block) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/revelry/content/configuration.rb', line 14 def user_for_content(&block) if block_given? @user_finder = block end @user_finder || default_user_finder end |