Class: RestfulSpec::Specification::SmartSelect
- Inherits:
-
Array
- Object
- Array
- RestfulSpec::Specification::SmartSelect
- Defined in:
- lib/restful_spec/specification.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #_included_(matcher) ⇒ Object
- #add(matcher) ⇒ Object
-
#initialize(*args, &block) ⇒ SmartSelect
constructor
A new instance of SmartSelect.
- #reject(matcher) ⇒ Object (also: #reject!)
- #select(matcher) ⇒ Object (also: #select!)
Constructor Details
#initialize(*args, &block) ⇒ SmartSelect
Returns a new instance of SmartSelect.
158 159 160 161 162 |
# File 'lib/restful_spec/specification.rb', line 158 def initialize(*args, &block) @options = args. super(args.first.to_a) instance_eval(&block) if block_given? end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
152 153 154 |
# File 'lib/restful_spec/specification.rb', line 152 def @options end |
Instance Method Details
#_included_(matcher) ⇒ Object
154 155 156 |
# File 'lib/restful_spec/specification.rb', line 154 def _included_(matcher) ->(item) { Array.wrap([matcher]).include?(item) } end |
#add(matcher) ⇒ Object
164 165 166 |
# File 'lib/restful_spec/specification.rb', line 164 def add(matcher) self.replace self + Array.wrap([matcher]) end |
#reject(matcher) ⇒ Object Also known as: reject!
174 175 176 |
# File 'lib/restful_spec/specification.rb', line 174 def reject(matcher) self.replace( super &_included_(matcher) ) if [matcher].present? end |
#select(matcher) ⇒ Object Also known as: select!
168 169 170 |
# File 'lib/restful_spec/specification.rb', line 168 def select(matcher) self.replace( super &_included_(matcher) ) if [matcher].present? end |