Module: Stubbable

Extended by:
ActiveSupport::Concern
Included in:
ActiveRecord::Base
Defined in:
lib/acts_as_stubbable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#columnObject



19
20
21
22
# File 'lib/acts_as_stubbable.rb', line 19

def column
    # query the class this object belongs to to find the value
    self.class.column
end

#make_stubObject



10
11
12
13
14
15
16
17
# File 'lib/acts_as_stubbable.rb', line 10

def make_stub
  if !self.stub.blank?
    self.stub = self.stub.parameterize
  else
    self.stub = self.send(self.column).parameterize
  end
  self.errors.add(:stub, "cannot be blank") if self.stub == ''
end