Class: Statefulton::Statefulton

Inherits:
Object
  • Object
show all
Defined in:
lib/statefulton/statefulton.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Statefulton

Returns a new instance of Statefulton.



5
6
7
# File 'lib/statefulton/statefulton.rb', line 5

def initialize &block
  instance_eval &block
end

Instance Attribute Details

#instanceObject (readonly)

Returns the value of attribute instance.



3
4
5
# File 'lib/statefulton/statefulton.rb', line 3

def instance
  @instance
end

Instance Method Details

#builder(&block) ⇒ Object



9
10
11
# File 'lib/statefulton/statefulton.rb', line 9

def builder &block
  @builder = block
end

#expects(string) ⇒ Object



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

def expects string
  define_singleton_method string do
    instance or fail Exceptions::NoInstance
  end
end

#make(string, &block) ⇒ Object



13
14
15
16
17
# File 'lib/statefulton/statefulton.rb', line 13

def make string, &block
  define_singleton_method string do
    build_instance &block
  end
end

#reset!Object



25
26
27
# File 'lib/statefulton/statefulton.rb', line 25

def reset!
  @instance = nil
end