Class: Sinatra::Rabbit::Feature
- Inherits:
-
Object
- Object
- Sinatra::Rabbit::Feature
- Defined in:
- lib/sinatra/rabbit/features.rb
Defined Under Namespace
Classes: Operation
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#description(s = nil) ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
Instance Method Summary collapse
- #constraint(name, value) ⇒ Object
-
#initialize(name, opts = {}, &block) ⇒ Feature
constructor
A new instance of Feature.
- #operation(name, &block) ⇒ Object
Constructor Details
#initialize(name, opts = {}, &block) ⇒ Feature
Returns a new instance of Feature.
26 27 28 29 30 31 32 33 |
# File 'lib/sinatra/rabbit/features.rb', line 26 def initialize(name, opts={}, &block) @name = name @operations = [] @collection = opts[:for] @constraints = {} raise "Each feature must define collection for which it will be valid using :for parameter" unless @collection instance_eval(&block) if block_given? end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
22 23 24 |
# File 'lib/sinatra/rabbit/features.rb', line 22 def collection @collection end |
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
24 25 26 |
# File 'lib/sinatra/rabbit/features.rb', line 24 def constraints @constraints end |
#description(s = nil) ⇒ Object (readonly)
Returns the value of attribute description.
21 22 23 |
# File 'lib/sinatra/rabbit/features.rb', line 21 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/sinatra/rabbit/features.rb', line 20 def name @name end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
23 24 25 |
# File 'lib/sinatra/rabbit/features.rb', line 23 def operations @operations end |
Instance Method Details
#constraint(name, value) ⇒ Object
44 45 46 |
# File 'lib/sinatra/rabbit/features.rb', line 44 def constraint(name, value) @constraints[name] = value end |