Module: Progressive::Subject::ClassMethods

Defined in:
lib/progressive/subject.rb

Instance Method Summary collapse

Instance Method Details

#specificationObject



27
28
29
# File 'lib/progressive/subject.rb', line 27

def specification
  Progressive.specifications[name]
end

#specification=(specification) ⇒ Object



23
24
25
# File 'lib/progressive/subject.rb', line 23

def specification=(specification)
  Progressive.specifications[name] = specification
end

#states(options = {}, &block) ⇒ Object

Public: Define the different states and events the subject can go through.

options - The Hash options used to build the specification (default: {}):

:default - The default state the subject is instantiated at (optional).

block - A required block that is used to define states and events for

the subject.

Returns Progression::Specification



18
19
20
21
# File 'lib/progressive/subject.rb', line 18

def states(options = {}, &block)
  self.specification = Specification.new(options, &block)
  define_model_callbacks(*specification.event_names, only: [:before, :after])
end