Sha256: b01e0d53471974c2ac76e71104cc424dc5385e57054ee0d77bf435d7aa454e40

Contents?: true

Size: 839 Bytes

Versions: 11

Compression:

Stored size: 839 Bytes

Contents

module EnjuMessage
  module MessageUser
    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def enju_message_user_model
        include InstanceMethods
        has_many :sent_messages, :foreign_key => 'sender_id', :class_name => 'Message'
        has_many :received_messages, :foreign_key => 'receiver_id', :class_name => 'Message'
      end
    end

    module InstanceMethods
      def send_message(status, options = {})
        MessageRequest.transaction do
          request = MessageRequest.new
          request.sender = self.class.find(1)
          request.receiver = self
          request.message_template = MessageTemplate.localized_template(status, self.locale)
          request.save_message_body(options)
          request.sm_send_message!
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
enju_message-0.1.14.pre14 lib/enju_message/user.rb
enju_message-0.1.14.pre13 lib/enju_message/user.rb
enju_message-0.1.14.pre12 lib/enju_message/user.rb
enju_message-0.1.14.pre11 lib/enju_message/user.rb
enju_message-0.1.14.pre10 lib/enju_message/user.rb
enju_message-0.1.14.pre9 lib/enju_message/user.rb
enju_message-0.1.14.pre8 lib/enju_message/user.rb
enju_message-0.1.14.pre7 lib/enju_message/user.rb
enju_message-0.1.14.pre6 lib/enju_message/user.rb
enju_message-0.1.14.pre5 lib/enju_message/user.rb
enju_message-0.1.14.pre4 lib/enju_message/user.rb