Sha256: ac786619ef5f5046326681b007919c5fafdf6c0496123643480f078447bdd210

Contents?: true

Size: 236 Bytes

Versions: 3

Compression:

Stored size: 236 Bytes

Contents

class Token < ActiveRecord::Base
  belongs_to :parent, :polymorphic => true
  
  named_scope :for, lambda{|k| {:conditions => {:parent_type => k.to_s.classify}} }
  
  def self.get(value)
    find_by_value(value).try(:parent)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
laserlemon-has_token-0.3.0 lib/token.rb
laserlemon-has_token-0.3.1 lib/token.rb
laserlemon-has_token-0.3.2 lib/token.rb