Module: Oauned::Models::Application

Defined in:
lib/oauned/models/application.rb

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/oauned/models/application.rb', line 2

def self.included(klass)
  Oauned::Models['application'] = klass

  klass.class_eval do
    before_validation    :set_default,
      :on => :create

    def authorize!(user)
      Oauned::Models['authorization'].create!(:user_id => user.id, :application_id => id)
    end

    private
    def set_default
      self.consumer_secret = SecureRandom.hex(40)
    end
  end
end