Module: SpeakingUrl::MongoResource

Defined in:
lib/speaking_url/mongo_resource.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cocktailsObject



18
19
20
# File 'lib/speaking_url/mongo_resource.rb', line 18

def self.cocktails
  @@cocktails
end

.included(klass) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/speaking_url/mongo_resource.rb', line 6

def self.included(klass)
  @@cocktails ||= []
  @@cocktails.push(klass).uniq!

  klass.instance_eval do 
    include Mongoid::Document
    field :urls, :type => Array, :default => []
  end

  klass.extend(ClassMethods)
end

Instance Method Details

#add_mapping(new_url) ⇒ Object



26
27
28
# File 'lib/speaking_url/mongo_resource.rb', line 26

def add_mapping(new_url)
  urls << new_url
end

#current_urlObject



22
23
24
# File 'lib/speaking_url/mongo_resource.rb', line 22

def current_url
  urls.last
end