Class: Fakerize::Model
- Inherits:
-
Object
- Object
- Fakerize::Model
- Defined in:
- lib/fakerize/model.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model, config = {}) ⇒ Model
constructor
A new instance of Model.
- #perform ⇒ Object
Constructor Details
#initialize(model, config = {}) ⇒ Model
Returns a new instance of Model.
4 5 6 7 |
# File 'lib/fakerize/model.rb', line 4 def initialize(model, config = {}) @model = model @config = Fakerize::Configuration.new default_config.merge(config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
2 3 4 |
# File 'lib/fakerize/model.rb', line 2 def config @config end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
2 3 4 |
# File 'lib/fakerize/model.rb', line 2 def model @model end |
Instance Method Details
#perform ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fakerize/model.rb', line 9 def perform config.attributes.each do |attribute| # Example: user.first_name= model.send "#{attribute}=", config.send(attribute).call end # Example: :remove_profile_image! before_save_methods.each { |method| model.send(method) } model.save! end |