Sha256: d240951b0e0430b09da20969711a1b02503d3377f171377a6529522a7945f8f4

Contents?: true

Size: 422 Bytes

Versions: 1

Compression:

Stored size: 422 Bytes

Contents

module WithEditionMode
  extend ActiveSupport::Concern

  attr_accessor :edition_mode

  def edit!
    self.edition_mode = true
  end

  module ClassMethods
    def editable(*selectors)
      selectors.each { |selector| editable_field selector }
    end

    private

    def editable_field(selector)
      patch selector do |*args, hyper|
        edition_mode ? self[selector] : hyper.(*args)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mumuki-domain-6.3.0 app/models/concerns/with_edition_mode.rb