Sha256: be90650bf68f63eeb61c4beb8dc05611e03a109f35040745e8ca6e7a47cb3a4e

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Vedeu

  module Presentation

    # Provides style related presentation behaviour.
    #
    module Styles

      include Vedeu::Common

      # @return [NilClass|String|Symbol]
      def name
        if present?(@name)
          @name

        elsif parent && present?(parent.name)
          parent.name

        end
      end

      # @return [NilClass|void]
      def parent
        present?(@parent) ? @parent : nil
      end

      # 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

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.8.13 lib/vedeu/presentation/styles.rb
vedeu-0.8.12 lib/vedeu/presentation/styles.rb
vedeu-0.8.10 lib/vedeu/presentation/styles.rb
vedeu-0.8.9 lib/vedeu/presentation/styles.rb
vedeu-0.8.8 lib/vedeu/presentation/styles.rb
vedeu-0.8.7 lib/vedeu/presentation/styles.rb
vedeu-0.8.6 lib/vedeu/presentation/styles.rb
vedeu-0.8.5 lib/vedeu/presentation/styles.rb