Sha256: 198be436b8077b2fe1613babee9acb78beb409c44ffd873d870b45c1e69e8448

Contents?: true

Size: 510 Bytes

Versions: 10

Compression:

Stored size: 510 Bytes

Contents

module Spree::TokenResource

  module ClassMethods
    def token_resource
      has_one :tokenized_permission, :as => :permissable
      delegate :token, :to => :tokenized_permission, :allow_nil => true
      after_create :create_token
    end
  end

  module InstanceMethods
    def create_token
      create_tokenized_permission(:token => ::SecureRandom::hex(8))
      token
    end
  end

  def self.included(receiver)
    receiver.extend ClassMethods
    receiver.send :include, InstanceMethods
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spree_auth-0.70.7 lib/spree/token_resource.rb
spree_auth-0.70.6 lib/spree/token_resource.rb
spree_auth-0.70.5 lib/spree/token_resource.rb
spree_auth-0.70.4 lib/spree/token_resource.rb
spree_auth-0.70.3 lib/spree/token_resource.rb
spree_auth-0.70.2 lib/spree/token_resource.rb
spree_auth-0.70.1 lib/spree/token_resource.rb
spree_auth-0.70.0 lib/spree/token_resource.rb
spree_auth-0.70.0.rc2 lib/spree/token_resource.rb
spree_auth-0.70.RC1 lib/spree/token_resource.rb