Sha256: ec32cd1908df83a1f82e8969e7862643593b50ffbd0e48147727e68f857bd65d

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

module Ocp::Registry::Models
  class RegistryApplication < Sequel::Model
  	def before_create
  		values[:id] = Ocp::Registry::Common.uuid
  		values[:created_at] = Time.now.utc.to_s
  		values[:state] = 'PENDING'
  	end

  	one_to_many :registry_settings, :select => [:id ,:comments, :settings, :updated_at, :from], :order => :version

  	def to_hash(opts = {})
  		hash = self.values
  		if false == opts[:lazy_load]
  			settings = []
  			self.registry_settings do |data|
          limit = opts[:limit]
          data = data.limit(limit) if limit
          data.reverse(:version).each do |set|
    				settings << set.to_hash
          end
  			end
  			hash[:registry_settings] = settings
  		end
  		Ocp::Registry::Common.deep_copy(hash)
  	end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ocp_registry-0.0.5.pre lib/ocp_registry/models/registry_application.rb