Sha256: 10c36aa506dc8778012c60cec9436c36323773b797f4cf3ac284bec56dc4fb46

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

module Vedeu

  # Change the visibility of the given model.
  class Visibility

    # @param name [String]
    # @return [Vedeu::Visibility]
    def self.for_cursor(name = nil)
      named = name ? Vedeu.cursors.by_name(name) : Vedeu.cursor

      new(named)
    end

    # @param model [void]
    # @return [void]
    def self.show(model)
      new(model).show
    end

    # @param model [void]
    # @return [void]
    def self.hide(model)
      new(model).hide
    end

    # @param model [void]
    # @return [void]
    def self.toggle(model)
      new(model).toggle
    end

    # @param model [void]
    # @return [Vedeu::Visibility]
    def initialize(model)
      @model = model
    end

    # @return [void]
    def show
      model.visible = true
      model.store
    end

    # @return [Symbol]
    def state
      if model.visible?
        :visible

      else
        :invisible

      end
    end

    # @return [void]
    def hide
      model.visible = false
      model.store
    end

    # @return [void]
    def toggle
      if model.visible?
        hide

      else
        show

      end
    end

    protected

    # @!attribute [r] model
    # @return [void]
    attr_reader :model

  end # Visibility

end # Vedeu

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.4.26 lib/vedeu/support/visibility.rb
vedeu-0.4.25 lib/vedeu/support/visibility.rb
vedeu-0.4.24 lib/vedeu/support/visibility.rb
vedeu-0.4.23 lib/vedeu/support/visibility.rb
vedeu-0.4.22 lib/vedeu/support/visibility.rb
vedeu-0.4.21 lib/vedeu/support/visibility.rb
vedeu-0.4.20 lib/vedeu/support/visibility.rb
vedeu-0.4.19 lib/vedeu/support/visibility.rb