Class: Bparity::Adapter::Subject
- Inherits:
-
Object
- Object
- Bparity::Adapter::Subject
- Defined in:
- lib/bparity/adapter.rb
Instance Attribute Summary collapse
-
#constructor ⇒ Object
Returns the value of attribute constructor.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
-
#state_projection ⇒ Object
Returns the value of attribute state_projection.
Instance Method Summary collapse
- #build(context = {}) ⇒ Object
- #construct(&block) ⇒ Object
-
#initialize(name) ⇒ Subject
constructor
A new instance of Subject.
- #operation(name, &block) ⇒ Object
- #state(&block) ⇒ Object
Constructor Details
#initialize(name) ⇒ Subject
Returns a new instance of Subject.
35 36 37 38 |
# File 'lib/bparity/adapter.rb', line 35 def initialize(name) @name = name @operations = {} end |
Instance Attribute Details
#constructor ⇒ Object
Returns the value of attribute constructor.
33 34 35 |
# File 'lib/bparity/adapter.rb', line 33 def constructor @constructor end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
32 33 34 |
# File 'lib/bparity/adapter.rb', line 32 def name @name end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
32 33 34 |
# File 'lib/bparity/adapter.rb', line 32 def operations @operations end |
#state_projection ⇒ Object
Returns the value of attribute state_projection.
33 34 35 |
# File 'lib/bparity/adapter.rb', line 33 def state_projection @state_projection end |
Instance Method Details
#build(context = {}) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/bparity/adapter.rb', line 49 def build(context = {}) unless constructor raise ConfigurationError, "Adapter subject #{name} has no constructor. Add a construct block to the adapter." end constructor.call(context) end |
#construct(&block) ⇒ Object
40 |
# File 'lib/bparity/adapter.rb', line 40 def construct(&block) = self.constructor = block |
#operation(name, &block) ⇒ Object
43 44 45 46 47 |
# File 'lib/bparity/adapter.rb', line 43 def operation(name, &block) item = Operation.new(name: name) OperationDsl.new(item).instance_eval(&block) if block operations[name] = item end |
#state(&block) ⇒ Object
41 |
# File 'lib/bparity/adapter.rb', line 41 def state(&block) = self.state_projection = block |