Class: DactylForm
- Inherits:
-
Object
- Object
- DactylForm
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/dactyl_form.rb
Overview
TODO Thread safety TODO Raise exceptions on invalid input TODO Possible normalizations infinite loop TODO Comments TODO (attribute)_change inspection and handling TODO Readme file TODO License file
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #creating? ⇒ Boolean
- #http_method ⇒ Object
-
#initialize(object, params = nil) ⇒ DactylForm
constructor
A new instance of DactylForm.
- #process ⇒ Object
- #updating? ⇒ Boolean
Constructor Details
#initialize(object, params = nil) ⇒ DactylForm
Returns a new instance of DactylForm.
15 16 17 18 19 20 21 |
# File 'lib/dactyl_form.rb', line 15 def initialize(object, params = nil) @object = object @params = params @attribute_cache = {} @persisted = object.persisted? self.class.define_getters unless self.class.getters_defined? end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
13 14 15 |
# File 'lib/dactyl_form.rb', line 13 def object @object end |
Instance Method Details
#creating? ⇒ Boolean
31 32 33 |
# File 'lib/dactyl_form.rb', line 31 def creating? !updating? end |
#http_method ⇒ Object
23 24 25 |
# File 'lib/dactyl_form.rb', line 23 def http_method updating? ? :put : :post end |
#process ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/dactyl_form.rb', line 35 def process if valid? save_object true else restore_params false end end |
#updating? ⇒ Boolean
27 28 29 |
# File 'lib/dactyl_form.rb', line 27 def updating? persisted? end |