Class: ARMocker::Model
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- ARMocker::Model
- Defined in:
- lib/a_r_mocker/model.rb
Overview
Object that acts as an ActiveRecord model so form objects can use them as dummy data
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Model
constructor
A new instance of Model.
-
#to_param ⇒ Object
for generating path from object (e.g. edit_model_path(model)) For context, see ActionDispatch::Routing::RouteSet::Generator::PARAMETERIZE.
Constructor Details
#initialize(hash = {}) ⇒ Model
Returns a new instance of Model.
5 6 7 8 9 |
# File 'lib/a_r_mocker/model.rb', line 5 def initialize(hash = {}) @persisted = hash.slice(:_persisted) hash = default_attributes.merge(hash) super end |
Class Method Details
.create(hash = {}) ⇒ Object
11 12 13 |
# File 'lib/a_r_mocker/model.rb', line 11 def self.create(hash = {}) new(hash.merge(_persisted: true)) end |
Instance Method Details
#to_param ⇒ Object
for generating path from object (e.g. edit_model_path(model)) For context, see ActionDispatch::Routing::RouteSet::Generator::PARAMETERIZE
27 28 29 |
# File 'lib/a_r_mocker/model.rb', line 27 def to_param id end |