Sha256: 5435028b9a1649b3eca060175ddd62a480e43c4cf6d3532f5c2a00b51626cd09

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module Vedeu

  module Presentation

    # Provides style related presentation behaviour.
    #
    module Styles

      include Vedeu::Common
      include Vedeu::Repositories::Parent

      # When the style for the model exists, return it, otherwise
      # returns the parent style, or an empty
      # {Vedeu::Presentation::Style}.
      #
      # @return [Vedeu::Presentation::Style]
      def style
        @_style ||= if @style
                      Vedeu::Presentation::Style.coerce(@style)

                    elsif parent && present?(parent.style)
                      Vedeu::Presentation::Style.coerce(parent.style)

                    else
                      Vedeu::Presentation::Style.new

                    end
      end

      # Allows the setting of the style by coercing the given value
      # into a {Vedeu::Presentation::Style}.
      #
      # @return [Vedeu::Presentation::Style]
      def style=(value)
        @_style = @style = Vedeu::Presentation::Style.coerce(value)
      end

    end # Style

  end # Presentation

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.8.4 lib/vedeu/presentation/styles.rb
vedeu-0.8.3 lib/vedeu/presentation/styles.rb