Class: MetaDefinition
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- MetaDefinition
- Defined in:
- app/models/meta_definition.rb
Instance Method Summary collapse
- #allowed?(user, action) ⇒ Boolean
- #autherisation ⇒ Object
- #field_map ⇒ Object
- #flash_messages ⇒ Object
-
#template_filename(include_extension = true) ⇒ Object
Used to find template named after label_path eg.
Instance Method Details
#allowed?(user, action) ⇒ Boolean
35 36 37 38 39 40 41 42 43 |
# File 'app/models/meta_definition.rb', line 35 def allowed?(user, action) tokens = (autherisation[action] || Settings.documents.autherisation.send(action)).split(' ') tokens.each do | token | return true if token == 'all' return true if token == 'author' && self. == user return true if user.has_role? token end false end |
#autherisation ⇒ Object
22 23 24 |
# File 'app/models/meta_definition.rb', line 22 def autherisation super || {} end |
#field_map ⇒ Object
26 27 28 |
# File 'app/models/meta_definition.rb', line 26 def field_map super || {} end |
#flash_messages ⇒ Object
30 31 32 |
# File 'app/models/meta_definition.rb', line 30 def super || {} end |
#template_filename(include_extension = true) ⇒ Object
Used to find template named after label_path eg. blog.post.html.erb
47 48 49 |
# File 'app/models/meta_definition.rb', line 47 def template_filename(include_extension = true) label_path.gsub('/', '.') + (include_extension ? '.html.erb' : '') end |