Module: SfCli::Sf::Apex::Generate

Included in:
Core
Defined in:
lib/sf_cli/sf/apex/generate.rb

Instance Method Summary collapse

Instance Method Details

#generate_class(name, output_dir: nil, template: nil, api_version: nil, raw_output: false) ⇒ Array

Generate an Apex class

Parameters:

  • name (String, Symbol)

    Apex class name

  • output_dir (String) (defaults to: nil)

    directory for saving the created files

  • template (String, Symbol) (defaults to: nil)

    template to use for file creation.Permissible values are: ApexException, ApexUnitTest, BasicUnitTest, DefaultApexClass, InboundEmailService

  • api_version (Numeric) (defaults to: nil)

    override the api version used for api requests made by this command

  • raw_output (Boolian) (defaults to: false)

    output what original command shows

Returns:

  • (Array)

    the list of files that is created

See Also:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sf_cli/sf/apex/generate.rb', line 14

def generate_class(name, output_dir: nil, template: nil, api_version: nil, raw_output: false)
  flags = {
    :"name" => name,
    :"output-dir" => output_dir,
    :"template" => template,
    :"api-version" => api_version,
  }
  switches = {
  }
  command_output_format = raw_output ? :human : :json
  redirect_type = raw_output ? nil : :null_stderr
  action = __method__.to_s.tr('_', ' ')
  output = exec(action, flags: flags, switches: switches, redirection: redirect_type, raw_output: raw_output, format: command_output_format)
  return output if raw_output

  output['result']['created']
end

#generate_trigger(name, output_dir: nil, sobject: nil, event: nil, api_version: nil, raw_output: false) ⇒ Array

Generate an Apex trigger

Parameters:

  • name (String, Symbol)

    Name of the generated Apex trigger

  • output_dir (String) (defaults to: nil)

    directory for saving the created files

  • sobject (String, Symbol) (defaults to: nil)

    Salesforce object to generate a trigger on

  • event (Array) (defaults to: nil)

    Events that fire the trigger.Permissible values are: “before insert”, “before update”, “before delete”, “after insert”, “after update”, “after delete”, “after undelete”

  • api_version (Numeric) (defaults to: nil)

    override the api version used for api requests made by this command

  • raw_output (Boolian) (defaults to: false)

    output what original command shows

Returns:

  • (Array)

    the list of files that is created

See Also:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/sf_cli/sf/apex/generate.rb', line 44

def generate_trigger(name, output_dir: nil, sobject: nil, event: nil, api_version: nil, raw_output: false)
  flags = {
    :"name" => name,
    :"output-dir" => output_dir,
    :"sobject" => sobject,
    :"event" => event&.map{|ev| %|"#{ev}"|}&.join(' '),
    :"api-version" => api_version,
  }
  switches = {
  }
  command_output_format = raw_output ? :human : :json
  redirect_type = raw_output ? nil : :null_stderr
  action = __method__.to_s.tr('_', ' ')
  output = exec(action, flags: flags, switches: switches, redirection: redirect_type, raw_output: raw_output, format: command_output_format)
  return output if raw_output

  output['result']['created']
end