Sha256: aa9e3bc9670a52c76536bfa8af9aeb3e610351dc040a72b122a64e0c71ecada3

Contents?: true

Size: 509 Bytes

Versions: 12

Compression:

Stored size: 509 Bytes

Contents

module Property
  class Label
    attr_accessor :post

    def name
      "label"
    end

    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

    def destroy(params)
      label = ::Label.find_by!(name: params[:value])
      labels = post.labels
      labels.delete(label)
      post.labels = labels
      post.save!
      label
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ecrire-0.26.2 lib/ecrire/app/models/property/label.rb
ecrire-0.26.1 lib/ecrire/app/models/property/label.rb
ecrire-0.26.0 lib/ecrire/app/models/property/label.rb
ecrire-0.25.2 lib/ecrire/app/models/property/label.rb
ecrire-0.25.1 lib/ecrire/app/models/property/label.rb
ecrire-0.25.0 lib/ecrire/app/models/property/label.rb
ecrire-0.24.1 lib/ecrire/app/models/property/label.rb
ecrire-0.24.0 lib/ecrire/app/models/property/label.rb
ecrire-0.23.0 lib/ecrire/app/models/property/label.rb
ecrire-0.22.1 lib/ecrire/app/models/property/label.rb
ecrire-0.21.0 lib/ecrire/app/models/property/label.rb
ecrire-0.20.0 lib/ecrire/app/models/property/label.rb