Class: MetaDefinition

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/meta_definition.rb

Instance Method Summary collapse

Instance Method Details

#allowed?(user, action) ⇒ Boolean

Returns:

  • (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.author == user
    return true if user.has_role? token
  end
  false
end

#autherisationObject



22
23
24
# File 'app/models/meta_definition.rb', line 22

def autherisation
  super || {}
end

#field_mapObject



26
27
28
# File 'app/models/meta_definition.rb', line 26

def field_map
  super || {}
end

#flash_messagesObject



30
31
32
# File 'app/models/meta_definition.rb', line 30

def flash_messages
  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