Module: Mist::Configuration
- Included in:
- Mist
- Defined in:
- lib/mist/configuration.rb
Defined Under Namespace
Classes: Author
Instance Method Summary collapse
- #author ⇒ Object
- #authorizations ⇒ Object
-
#authorize(*types, &block) ⇒ Object
Register a block to be invoked whenever Mist needs to know if a user is allowed to perform some action, such as :create_post, :edit_post, :view_post, :destroy_post, or :all.
-
#authorized?(action, *args) ⇒ Boolean
Invokes the blocks registered by Mist::Configuration#authorize to see if the specified action is authorized.
- #commit_meta_data ⇒ Object
- #commit_meta_data=(a) ⇒ Object
- #default_repository_location ⇒ Object
- #repository_location ⇒ Object
- #repository_location=(dir) ⇒ Object
- #reset_authorizations! ⇒ Object
- #title ⇒ Object
- #title=(title) ⇒ Object
Instance Method Details
#author ⇒ Object
32 33 34 |
# File 'lib/mist/configuration.rb', line 32 def @author ||= Mist::Configuration::Author.new end |
#authorizations ⇒ Object
20 21 22 |
# File 'lib/mist/configuration.rb', line 20 def @authorizations ||= {}.with_indifferent_access end |
#authorize(*types, &block) ⇒ Object
Register a block to be invoked whenever Mist needs to know if a user is allowed to perform some action, such as :create_post, :edit_post, :view_post, :destroy_post, or :all.
Mist.authorize { |controller| ... } # invoke for any action not otherwise registered
Mist.authorize(:all) { |controller| ... } # same as above
Mist.authorize(:create_post) { |controller| ... } # use this block only for :create_post
By default, all authorization requests will return false (denied).
54 55 56 57 58 |
# File 'lib/mist/configuration.rb', line 54 def (*types, &block) raise ArgumentError, "Expected a block which will be evaluated at runtime" unless block_given? types.push :all if types.empty? types.each { |type| [type] = block } end |
#authorized?(action, *args) ⇒ Boolean
Invokes the blocks registered by Mist::Configuration#authorize to see if the specified action is authorized. Passes *args into the block.
62 63 64 65 66 67 |
# File 'lib/mist/configuration.rb', line 62 def (action, *args) if .key?(action) then [action].call *args elsif .key?(:all) then [:all].call *args else nil end end |
#commit_meta_data ⇒ Object
24 25 26 |
# File 'lib/mist/configuration.rb', line 24 def @commit_meta_data = true if @commit_meta_data.nil? end |
#commit_meta_data=(a) ⇒ Object
28 29 30 |
# File 'lib/mist/configuration.rb', line 28 def (a) @commit_meta_data = a end |
#default_repository_location ⇒ Object
12 13 14 |
# File 'lib/mist/configuration.rb', line 12 def default_repository_location Rails.root.join("db/mist.repo.#{Rails.env}") end |
#repository_location ⇒ Object
4 5 6 |
# File 'lib/mist/configuration.rb', line 4 def repository_location @respository_location ||= default_repository_location end |
#repository_location=(dir) ⇒ Object
8 9 10 |
# File 'lib/mist/configuration.rb', line 8 def repository_location=(dir) @respository_location = dir end |
#reset_authorizations! ⇒ Object
16 17 18 |
# File 'lib/mist/configuration.rb', line 16 def .clear end |
#title ⇒ Object
40 41 42 |
# File 'lib/mist/configuration.rb', line 40 def title @title ||= "Blog Title" end |
#title=(title) ⇒ Object
36 37 38 |
# File 'lib/mist/configuration.rb', line 36 def title=(title) @title = title end |