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)
-
- (Object) collection
readonly
Returns the value of attribute collection.
-
- (Object) constraints
readonly
Returns the value of attribute constraints.
-
- (Object) description(s = nil)
readonly
Returns the value of attribute description.
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) operations
readonly
Returns the value of attribute operations.
Instance Method Summary (collapse)
- - (Object) constraint(name, value)
-
- (Feature) initialize(name, opts = {}, &block)
constructor
A new instance of Feature.
- - (Object) operation(name, &block)
Constructor Details
- (Feature) initialize(name, opts = {}, &block)
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
- (Object) collection (readonly)
Returns the value of attribute collection
22 23 24 |
# File 'lib/sinatra/rabbit/features.rb', line 22 def collection @collection end |
- (Object) constraints (readonly)
Returns the value of attribute constraints
24 25 26 |
# File 'lib/sinatra/rabbit/features.rb', line 24 def constraints @constraints end |
- (Object) description(s = nil) (readonly)
Returns the value of attribute description
21 22 23 |
# File 'lib/sinatra/rabbit/features.rb', line 21 def description @description end |
- (Object) name (readonly)
Returns the value of attribute name
20 21 22 |
# File 'lib/sinatra/rabbit/features.rb', line 20 def name @name end |
- (Object) operations (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
- (Object) constraint(name, value)
44 45 46 |
# File 'lib/sinatra/rabbit/features.rb', line 44 def constraint(name, value) @constraints[name] = value end |
- (Object) operation(name, &block)
35 36 37 38 |
# File 'lib/sinatra/rabbit/features.rb', line 35 def operation(name, &block) @operations << Operation.new(name, &block) if block_given? @operations.find { |o| o.name == name } end |