Class: Property::Label
- Inherits:
-
Object
- Object
- Property::Label
- Defined in:
- lib/ecrire/app/models/property/label.rb
Instance Attribute Summary collapse
-
#post ⇒ Object
Returns the value of attribute post.
Instance Method Summary collapse
Instance Attribute Details
#post ⇒ Object
Returns the value of attribute post.
3 4 5 |
# File 'lib/ecrire/app/models/property/label.rb', line 3 def post @post end |
Instance Method Details
#create(params) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/ecrire/app/models/property/label.rb', line 9 def create(params) new_label = ::Label.find_or_create_by!(name: params[:value]) labels = post.labels labels << new_label post.labels = labels post.save! new_label end |
#destroy(params) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/ecrire/app/models/property/label.rb', line 18 def destroy(params) label = ::Label.find_by!(name: params[:value]) labels = post.labels labels.delete(label) post.labels = labels post.save! label end |
#name ⇒ Object
5 6 7 |
# File 'lib/ecrire/app/models/property/label.rb', line 5 def name "label" end |