class Docks::Containers::Variation

Public Class Methods

new(variation_hash = {}) click to toggle source
Calls superclass method Docks::Containers::Symbol::new
# File lib/docks/containers/variation_container.rb, line 8
def initialize(variation_hash = {})
  super
  set_defaults
end
type() click to toggle source
# File lib/docks/containers/variation_container.rb, line 6
def self.type; "variation" end

Public Instance Methods

has_demo?() click to toggle source
# File lib/docks/containers/variation_container.rb, line 13
def has_demo?
  [Types::Demo::OWN, Types::Demo::JOINT].include?(demo_type)
end

Protected Instance Methods

matches_exactly?(descriptor) click to toggle source
# File lib/docks/containers/variation_container.rb, line 19
def matches_exactly?(descriptor)
  super || (descriptor.member? && descriptor.member == fetch(:name) && descriptor.symbol == fetch(:for, nil))
end
set_defaults() click to toggle source
# File lib/docks/containers/variation_container.rb, line 23
def set_defaults
  self[:active] = false if self[:active].nil?
  self[:demo_type] ||= Types::Demo::SELECT

  [:activate_with, :preclude, :set_by, :include_with].each do |defaults_to_array|
    value = self[defaults_to_array]
    self[defaults_to_array] = case value
      when NilClass then []
      when Array then value
      else [value]
    end
  end
end