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.10.0 app/models/refine/stabilize.rb
refine-rails-2.9.14 app/models/refine/stabilize.rb
refine-rails-2.9.13 app/models/refine/stabilize.rb
refine-rails-2.9.12 app/models/refine/stabilize.rb
refine-rails-2.9.11 app/models/refine/stabilize.rb
refine-rails-2.9.10 app/models/refine/stabilize.rb
refine-rails-2.9.9 app/models/refine/stabilize.rb
refine-rails-2.9.8 app/models/refine/stabilize.rb
refine-rails-2.9.7 app/models/refine/stabilize.rb
refine-rails-2.9.6 app/models/refine/stabilize.rb
refine-rails-2.9.5 app/models/refine/stabilize.rb
refine-rails-2.9.4 app/models/refine/stabilize.rb
refine-rails-2.9.3 app/models/refine/stabilize.rb
refine-rails-2.9.2 app/models/refine/stabilize.rb
refine-rails-2.9.1 app/models/refine/stabilize.rb
refine-rails-2.9.0 app/models/refine/stabilize.rb