Class: Revision::Factory
- Defined in:
- lib/controlled_versioning/revision/factory.rb
Instance Attribute Summary collapse
-
#suggested_attributes ⇒ Object
readonly
Returns the value of attribute suggested_attributes.
-
#version ⇒ Object
Returns the value of attribute version.
-
#versionable ⇒ Object
readonly
Returns the value of attribute versionable.
Instance Method Summary collapse
- #build ⇒ Object
- #build_associations ⇒ Object
-
#initialize(args) ⇒ Factory
constructor
A new instance of Factory.
Constructor Details
#initialize(args) ⇒ Factory
Returns a new instance of Factory.
5 6 7 8 9 |
# File 'lib/controlled_versioning/revision/factory.rb', line 5 def initialize(args) @versionable = args[:versionable] @version = args[:version] @suggested_attributes = args[:suggested_attributes] end |
Instance Attribute Details
#suggested_attributes ⇒ Object (readonly)
Returns the value of attribute suggested_attributes.
3 4 5 |
# File 'lib/controlled_versioning/revision/factory.rb', line 3 def suggested_attributes @suggested_attributes end |
#version ⇒ Object
Returns the value of attribute version.
4 5 6 |
# File 'lib/controlled_versioning/revision/factory.rb', line 4 def version @version end |
#versionable ⇒ Object (readonly)
Returns the value of attribute versionable.
3 4 5 |
# File 'lib/controlled_versioning/revision/factory.rb', line 3 def versionable @versionable end |
Instance Method Details
#build ⇒ Object
11 12 13 14 15 16 |
# File 'lib/controlled_versioning/revision/factory.rb', line 11 def build versionable.assign_attributes(suggested_attributes) versionable.valid? validate_presence_of_changes versionable.errors.present? ? versionable : build_parent end |
#build_associations ⇒ Object
18 19 20 21 22 |
# File 'lib/controlled_versioning/revision/factory.rb', line 18 def build_associations mark_for_removal build_attributes build_children end |