Class: Scribo::FormDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Scribo::FormDrop
- Defined in:
- app/drops/scribo/form_drop.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #class_name ⇒ Object
- #errors ⇒ Object
-
#initialize(model, attribute = nil) ⇒ FormDrop
constructor
A new instance of FormDrop.
Constructor Details
#initialize(model, attribute = nil) ⇒ FormDrop
Returns a new instance of FormDrop.
5 6 7 8 |
# File 'app/drops/scribo/form_drop.rb', line 5 def initialize(model, attribute = nil) @model = model @attribute = attribute end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
10 11 12 |
# File 'app/drops/scribo/form_drop.rb', line 10 def attribute @attribute end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
10 11 12 |
# File 'app/drops/scribo/form_drop.rb', line 10 def model @model end |
Instance Method Details
#class_name ⇒ Object
12 13 14 |
# File 'app/drops/scribo/form_drop.rb', line 12 def class_name model.class.name.gsub(/Drop$/, '') end |
#errors ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/drops/scribo/form_drop.rb', line 16 def errors errors = if @model&.instance_variable_get('@object') @model.instance_variable_get('@object').errors else ::ActiveModel::Errors.new([]) end ::Scribo::ActiveModel::ErrorsDrop.new errors end |