Skip to content

Commit

Permalink
add in rule reloading in development based on modified time stamps
Browse files Browse the repository at this point in the history
  • Loading branch information
urkle committed Feb 2, 2012
1 parent 2a07f2a commit a5e6bea
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/declarative_authorization/authorization.rb
Expand Up @@ -277,12 +277,23 @@ def roles_for (user)
def roles_with_hierarchy_for(user)
flatten_roles(roles_for(user))
end


def self.development_reload?
if Rails.env.development?
mod_time = AUTH_DSL_FILES.map { |m| File.mtime(m) }.flatten.max
@@auth_dsl_last_modified ||= mod_time
if mod_time > @@auth_dsl_last_modified
@@auth_dsl_last_modified = mod_time
return true
end
end
end

# Returns an instance of Engine, which is created if there isn't one
# yet. If +dsl_file+ is given, it is passed on to Engine.new and
# a new instance is always created.
def self.instance (dsl_file = nil)
if dsl_file
if dsl_file or development_reload?
@@instance = new(dsl_file)
else
@@instance ||= new
Expand Down

0 comments on commit a5e6bea

Please sign in to comment.