Sha256: a15a914bfea1d4cd52f2c4cfe7a222e056a82bdfaf3cc0fd7cefb6648489fca8
Contents?: true
Size: 1.88 KB
Versions: 10
Compression:
Stored size: 1.88 KB
Contents
module RailsConnector module Migrations class CmsBackend def read obj = find_migration_store_obj if obj obj[attribute_name] else initial_value end end def save(value) CmsRestApi.put( endpoint("objs/#{migration_store_obj.id}"), :obj => { attribute_name => value } ) end private def create # Create attribute CmsRestApi.post( endpoint('attributes'), :attribute => { :name => attribute_name, :type => :text, } ) # Create obj class CmsRestApi.post( endpoint('obj_classes'), :obj_class => { :name => obj_class_name, :attributes => [attribute_name], :type => :publication, :title => obj_class_name, } ) # Create obj CmsRestApi.post( endpoint('objs'), :obj => { :_path => path, :_obj_class => obj_class_name, attribute_name => initial_value, } ) # Deactivate obj class CmsRestApi.put( endpoint("obj_classes/#{obj_class_name}"), :obj_class => { :is_active => false, } ) end def migration_store_obj unless find_migration_store_obj create end find_migration_store_obj end def find_migration_store_obj Obj.find_by_path(path) end def attribute_name 'versions' end def obj_class_name 'MigrationStore' end def path '/_internal/migration-store' end def initial_value '' end def endpoint(path) "revisions/#{Workspace.current.revision_id}/#{path}" end end end end
Version data entries
10 entries across 10 versions & 1 rubygems