4 module ActiveRecordHelper
5 def self.included(base)
6 base.extend(ClassMethods)
7 base.__send__ :include, InstanceMethods
11 def get_author_from_roles roles
13 return role if role.is_a?(Author)
14 return role.author if role.is_a?(User)
15 return role.author if role.is_a?(Artist) and role.author
20 def get_artist_from_roles roles
22 return role.artist if role.is_a?(Author) and role.artist
23 return role.author.artist if role.is_a?(User) and role.author and role.author.artist
24 return role if role.is_a?(Artist)
29 def get_admin_from_roles roles
31 return role if role.is_a?(Admin)
38 module InstanceMethods
43 def guest_role_check roles
47 def reader_role_check roles
48 roles = [roles] unless roles.respond_to?(:each)
50 return true if role.is_a?(Author) or role.is_a?(Artist) or role.is_a?(Admin) or role.is_a?(User)
55 def resource_reader_role_check roles
56 roles = [roles] unless roles.respond_to?(:each)
58 return true if role.is_a?(Author) or role.is_a?(Artist) or role.is_a?(Admin) or role.is_a?(User) or role.is_a?(DemandUser)
63 def admin_role_check roles
64 roles = [roles] unless roles.respond_to?(:each)
66 return true if role.is_a?(Admin)
74 include ActiveRecordHelper