Module: PR::ActiveForm
- Defined in:
- lib/pr/active_form.rb
Defined Under Namespace
Modules: Compatibility
Class Method Summary collapse
Instance Method Summary collapse
- #persisted? ⇒ Boolean
- #to_key ⇒ Object
- #to_model ⇒ Object
- #to_param ⇒ Object
- #to_partial_path ⇒ Object
Class Method Details
.included(other) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/pr/active_form.rb', line 7 def self.included other other.send :include, Form other.send :include, ActiveModel::Validations other.send :attr_accessor, :id other.extend Compatibility end |
Instance Method Details
#persisted? ⇒ Boolean
29 30 31 |
# File 'lib/pr/active_form.rb', line 29 def persisted? !(id.nil?) end |
#to_key ⇒ Object
33 34 35 |
# File 'lib/pr/active_form.rb', line 33 def to_key [:id] if persisted? end |
#to_model ⇒ Object
25 26 27 |
# File 'lib/pr/active_form.rb', line 25 def to_model self end |
#to_param ⇒ Object
37 38 39 |
# File 'lib/pr/active_form.rb', line 37 def to_param id.to_s if persisted? end |
#to_partial_path ⇒ Object
20 21 22 23 |
# File 'lib/pr/active_form.rb', line 20 def to_partial_path name = self.class.model_name.downcase [name.pluralize,name].join '/' end |