Sha256: 7c87054982e8c17dd67ca117849193a39a6229fb327677372099d98dbfaba3e7
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
module Storytime module Concerns module StorytimeUser extend ActiveSupport::Concern module ClassMethods def storytime_user belongs_to :storytime_role, class_name: "Storytime::Role" has_many :storytime_posts, class_name: "Storytime::Post" has_many :storytime_pages, class_name: "Storytime::Page" has_many :storytime_media, class_name: "Storytime::Media" has_many :storytime_versions, class_name: "Storytime::Version" has_many :storytime_comments, class_name: "Storytime::Comment" class_eval <<-EOS def self.policy_class UserPolicy end def storytime_user? !storytime_role.nil? end EOS %w{admin editor writer}.each do |role_name| class_eval <<-EOS def storytime_#{role_name}? storytime_role && storytime_role.name == "#{role_name}" end EOS end end end end end end ActiveRecord::Base.send :include, Storytime::Concerns::StorytimeUser
Version data entries
4 entries across 4 versions & 1 rubygems