cloud_controller/app/models/service.rb
# Returns the service represented as a legacy hash
Returns the service represented as a legacy hash
Returns the service represented as a legacy hash
def as_legacy(user)
    tiers = {}
    sort_orders = {}
    self.plans.sort.each_index do |i|
      sort_orders[self.plans[i]] = i + 1
    end
    self.plans.each do |p|
      next unless visible_to_user?(user, p)
      tiers[p] = {
        :options => {},
        :order   => sort_orders[p],  
      }
      if self.plan_options.is_a?(Hash) && self.plan_options.has_key?(p)
        tiers[p][:options][:plan_option] = {
          :type        => 'value',
          :description => 'Which plan would you like to use',
          :values      => self.plan_options[p],
        }
      end
    end
    { :id      => self.id,
      :vendor  => self.name,
      :version => self.version,
      :tiers   => tiers,
      :type    => self.synthesize_service_type,
      :description => self.description || '-',
    }
  end
def as_legacy ( user ) tiers = { } sort_orders = { } self . plans . sort . each_index do | i | sort_orders [ self . plans [ i ] ] = i + 1 end self . plans . each do | p | next unless visible_to_user? ( user , p ) tiers [ p ] = { :options => { } , :order => sort_orders [ p ] , } if self . plan_options . is_a? ( Hash ) && self . plan_options . has_key? ( p ) tiers [ p ] [ :options ] [ :plan_option ] = { :type => 'value' , :description => 'Which plan would you like to use' , :values => self . plan_options [ p ] , } end end { :id => self . id , :vendor => self . name , :version => self . version , :tiers => tiers , :type => self . synthesize_service_type , :description => self . description || '-' , } end
Returns the service represented as a legacy hash
Returns the service represented as a legacy hash
# Synthesize tier info # Sort order expects to be keyed starting at 1 :/ # XXX - Sort order. Synthesized for now (alphabetical), may want to add support for this to svcs api. # Binding options should be included as well, but no longer # make sense as they are all strings...
user