Class: ActiveCucumber::Creator
- Inherits:
-
Object
- Object
- ActiveCucumber::Creator
- Includes:
- FactoryGirl::Syntax::Methods
- Defined in:
- lib/active_cucumber/creator.rb
Overview
Creates ActiveRecord entries with data from given Cucumber tables.
Instance Method Summary collapse
-
#factorygirl_attributes ⇒ Object
Returns the FactoryGirl version of this Creator’s attributes.
-
#initialize(attributes, context) ⇒ Creator
constructor
A new instance of Creator.
Constructor Details
#initialize(attributes, context) ⇒ Creator
Returns a new instance of Creator.
10 11 12 13 14 15 |
# File 'lib/active_cucumber/creator.rb', line 10 def initialize attributes, context @attributes = attributes context.each do |key, value| instance_variable_set "@#{key}", value end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments) ⇒ Object (private)
33 34 35 36 37 |
# File 'lib/active_cucumber/creator.rb', line 33 def method_missing method_name, *arguments # This is necessary so that a Creator subclass can access # methods of @attributes as if they were its own. @attributes.send method_name, *arguments end |
Instance Method Details
#factorygirl_attributes ⇒ Object
Returns the FactoryGirl version of this Creator’s attributes
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/active_cucumber/creator.rb', line 18 def factorygirl_attributes symbolize_attributes! @attributes.each do |key, value| next unless respond_to?(method = method_name(key)) if (result = send method, value) || value.nil? @attributes[key] = result if @attributes.key? key else @attributes.delete key end end end |