Sha256: 546fabf4fbd296d8563d0753cc5bcb03e97e8ca7888b1cd66291568c2363c5b3
Contents?: true
Size: 665 Bytes
Versions: 18
Compression:
Stored size: 665 Bytes
Contents
module Softwear module Auth module BelongsToUser extend ActiveSupport::Concern module ClassMethods def belongs_to_user_called(name, options = {}) foreign_key = "#{name}_id" class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name} @#{name} ||= User.find(#{name}_id) end def #{name}=(new) self.#{foreign_key} = new.id @#{name} = new end RUBY end def belongs_to_user belongs_to_user_called(:user) end end included do extend ClassMethods end end end end
Version data entries
18 entries across 18 versions & 1 rubygems