Module: Lore::Behaviours::Versioned
- Defined in:
- lib/lore/behaviours/versioned.rb
Instance Method Summary collapse
-
#commit ⇒ Object
Overloads commit so it increments the version attribute before saving instance to database.
-
#version_by(attrib) ⇒ Object
Defines attribute the version number is stored in.
Instance Method Details
#commit ⇒ Object
Overloads commit so it increments the version attribute before saving instance to database.
16 17 18 19 |
# File 'lib/lore/behaviours/versioned.rb', line 16 def commit() set_attribute_value(@version_attr, self.attr[@version_attr].to_i + 1) super() end |
#version_by(attrib) ⇒ Object
Defines attribute the version number is stored in. Default is ‘version’.
9 10 11 12 |
# File 'lib/lore/behaviours/versioned.rb', line 9 def version_by(attrib) @version_attr = attrib @version_attr_name = attrib.to_s.split('.')[-1].intern end |