Sha256: b316cc5480fbb4ab6ab7dacbe37775c8c1e53a53b000b132de97994fc80fbfb8

Contents?: true

Size: 953 Bytes

Versions: 19

Compression:

Stored size: 953 Bytes

Contents

# frozen_string_literal: true

module Vedeu

  module Coercers

    # Provides the mechanism to convert a value into a
    # {Vedeu::Presentation::Style}.
    #
    # @api private
    #
    class Style < Vedeu::Coercers::Coercer

      # Produces new objects of the correct class from the value,
      # ignores objects that have already been coerced.
      #
      # @return [Vedeu::Presentation::Style]
      def coerce
        if coerced?
          value

        elsif hash?(value)
          if present?(value[:style])
            if value[:style].is_a?(klass)
              value[:style]

            else
              Vedeu::Coercers::Style.coerce(value[:style])

            end

          else
            klass.new

          end

        else
          klass.new(value)

        end
      end

      private

      # @return [Class]
      def klass
        Vedeu::Presentation::Style
      end

    end # Style

  end # Coercers

end # Vedeu

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
vedeu-0.8.32 lib/vedeu/coercers/style.rb
vedeu-0.8.31 lib/vedeu/coercers/style.rb
vedeu-0.8.30 lib/vedeu/coercers/style.rb
vedeu-0.8.29 lib/vedeu/coercers/style.rb
vedeu-0.8.28 lib/vedeu/coercers/style.rb
vedeu-0.8.27 lib/vedeu/coercers/style.rb
vedeu-0.8.26 lib/vedeu/coercers/style.rb
vedeu-0.8.25 lib/vedeu/coercers/style.rb
vedeu-0.8.24 lib/vedeu/coercers/style.rb
vedeu-0.8.23 lib/vedeu/coercers/style.rb
vedeu-0.8.22 lib/vedeu/coercers/style.rb
vedeu-0.8.21 lib/vedeu/coercers/style.rb
vedeu-0.8.20 lib/vedeu/coercers/style.rb
vedeu-0.8.19 lib/vedeu/coercers/style.rb
vedeu-0.8.18 lib/vedeu/coercers/style.rb
vedeu-0.8.17 lib/vedeu/coercers/style.rb
vedeu-0.8.16 lib/vedeu/coercers/style.rb
vedeu-0.8.15 lib/vedeu/coercers/style.rb
vedeu-0.8.14 lib/vedeu/coercers/style.rb