Class: HmxClient::Command::Type

Inherits:
Base
  • Object
show all
Defined in:
lib/hmx/command/type.rb

Overview

Display and manage type information in hmx

Constant Summary

Constants inherited from Base

Base::FILE

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#hmx, #initialize, #loadConfig!, namespace, #removeConfig, #storeConfig, #writeConfig

Methods included from Helpers

#display, #display_row, #display_tab, #display_table, #error, #getFromUser, #longest

Constructor Details

This class inherits a constructor from HmxClient::Command::Base

Instance Method Details

#cloneObject

type:clone-ent

Clone the entitlements from one type to another

<srcType> <targType>



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/hmx/command/type.rb', line 31

def clone
     # We basically load the documents for sys.ent/type/[source]/query and sys.ent/type/[source]/query and copy them to the target
     sourceType = args.shift
     targetType = args.shift
     arr = JSON.parse(hmx.doGetContent(["sys.ent/type/#{ sourceType }/get"]))
     arr["MXEntitlement"]["entitlementPath"] = "type/#{ targetType }/get"
     hmx.doPutSimpleData([ "sys.ent/type/#{ targetType}/get", JSON.generate(arr)])

     arr = JSON.parse(hmx.doGetContent(["sys.ent/type/#{ sourceType }/query"]))
     arr["MXEntitlement"]["entitlementPath"] = "type/#{ targetType }/query"
     hmx.doPutSimpleData([ "sys.ent/type/#{ targetType}/query", JSON.generate(arr)])
     puts "Done..."
end

#createObject

type:create

Create a type with default settings - no triggers, no entitlements



20
21
22
23
24
# File 'lib/hmx/command/type.rb', line 20

def create
   typeInfo = { "name" => args.shift, "triggers" => [], "typeNature" => "CONTENT", "typeIndexScript" => ""  }
   hmx.doUpdateType([typeInfo])       
   puts "Done..."
end

#indexObject

type

Display information about a HMX type



13
14
15
# File 'lib/hmx/command/type.rb', line 13

def index
  puts JSON.pretty_generate(hmx.doGetType(args))
end