Skip to content

Commit

Permalink
refactored for late-binding of Role class
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianmandrup committed Jan 21, 2011
1 parent a545312 commit 7a2f1dd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/roles_generic/generic/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ def role_class
end

module ClassMethods
attr_accessor :class_constant

def role_class_name
@role_class_name
end

def role_class class_constant
const = class_constant.to_s.camelize
begin
@role_class_name = "#{const}".constantize
@role_class_name ||= "#{const}".constantize
rescue
puts "Role class constant '#{const}' is not defined so it could not be set!"
end
end

def role_class class_constant
@class_constant = class_constant
end
end
end

0 comments on commit 7a2f1dd

Please sign in to comment.