Class: CollectionsFactory
- Inherits:
-
Array
- Object
- Array
- CollectionsFactory
- Defined in:
- lib/test-factory/collections_factory.rb
Overview
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
CollectionsFactory
Use this as the superclass for your data object collection classes.
Class Method Summary collapse
-
.contains(klass) ⇒ Object
Defines the class of objects contained in the collection.
Instance Method Summary collapse
-
#initialize(browser) ⇒ CollectionsFactory
constructor
A new instance of CollectionsFactory.
Constructor Details
#initialize(browser) ⇒ CollectionsFactory
Returns a new instance of CollectionsFactory.
22 23 24 |
# File 'lib/test-factory/collections_factory.rb', line 22 def initialize(browser) @browser=browser end |
Class Method Details
.contains(klass) ⇒ Object
Defines the class of objects contained in the collection
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/test-factory/collections_factory.rb', line 27 def self.contains klass # Creates a method called "add" that will create the specified data # object and then add it as an item in the collection. # # Note that it's assumed that the target data object will have a # create method defined. If not, this will not work properly. define_method 'add' do |opts| element = klass.new @browser, opts element.create self << element end end |