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 17 18 19 20 21 |
# File 'lib/controlled_versioning/revision/factory.rb', line 11 def build versionable.assign_attributes(suggested_attributes) if versionable.invalid? versionable.errors elsif !Revision::Auditor.new(versionable).changes_original? versionable.errors[:base] << I18n.t("errors.messages.no_revisions_made") versionable.errors else build_parent end end |
#build_associations ⇒ Object
23 24 25 26 27 |
# File 'lib/controlled_versioning/revision/factory.rb', line 23 def build_associations mark_for_removal build_attributes build_children end |