Sha256: f898ca167fa9955554c45c7a814e3817ac704fa749fa36562a4f6b5c9203b8e2

Contents?: true

Size: 704 Bytes

Versions: 36

Compression:

Stored size: 704 Bytes

Contents

module Refine
  module Stabilize

    def automatically_stabilize?
      false
    end

    def automatic_stable_id_generator
      self.class.default_stabilizer
    end

    def to_optional_stable_id(stabilizer=nil)
      create_stable_id(stabilizer) if automatically_stabilize?
    end

    def create_stable_id(stabilizer=nil)
      make_stable_id_generator(stabilizer).new.to_stable_id(filter: self)
    end

    def make_stable_id_generator(stabilizer = nil)
      generator = stabilizer || automatic_stable_id_generator
      if generator.blank?
        raise ArgumentError.new('No stable id class set. Set using the default_stable_id_generator method')
      end
      generator
    end

  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
refine-rails-2.13.3 app/models/refine/stabilize.rb
refine-rails-2.13.2 app/models/refine/stabilize.rb
refine-rails-2.13.1 app/models/refine/stabilize.rb
refine-rails-2.13.0 app/models/refine/stabilize.rb
refine-rails-2.12.2 app/models/refine/stabilize.rb
refine-rails-2.12.1 app/models/refine/stabilize.rb
refine-rails-2.12.0 app/models/refine/stabilize.rb
refine-rails-2.11.12 app/models/refine/stabilize.rb
refine-rails-2.11.11 app/models/refine/stabilize.rb
refine-rails-2.11.10 app/models/refine/stabilize.rb
refine-rails-2.11.9 app/models/refine/stabilize.rb
refine-rails-2.11.8 app/models/refine/stabilize.rb
refine-rails-2.11.6 app/models/refine/stabilize.rb
refine-rails-2.11.5 app/models/refine/stabilize.rb
refine-rails-2.11.4 app/models/refine/stabilize.rb
refine-rails-2.11.3 app/models/refine/stabilize.rb
refine-rails-2.11.2 app/models/refine/stabilize.rb
refine-rails-2.11.1 app/models/refine/stabilize.rb
refine-rails-2.11.0 app/models/refine/stabilize.rb
refine-rails-2.10.1 app/models/refine/stabilize.rb