Class: Ralph::CLI::Commands::Post
- Defined in:
- lib/ralph/cli/commands/post.rb
Class Attribute Summary collapse
-
.path ⇒ Object
Returns the value of attribute path.
-
.required_parameters ⇒ Object
Returns the value of attribute required_parameters.
Instance Method Summary collapse
- #call(**options) ⇒ Object
- #path ⇒ Object
- #path=(v) ⇒ Object
- #required_parameters ⇒ Object
- #required_parameters=(v) ⇒ Object
Methods inherited from Base
Class Attribute Details
.path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/ralph/cli/commands/post.rb', line 4 def path @path end |
.required_parameters ⇒ Object
Returns the value of attribute required_parameters.
5 6 7 |
# File 'lib/ralph/cli/commands/post.rb', line 5 def required_parameters @required_parameters end |
Instance Method Details
#call(**options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ralph/cli/commands/post.rb', line 22 def call(**) client = gen_client if file = [:file] json = File.open(file) {|io| JSON.load(io.read) } [json].flatten.each do |item| puts JSON.dump(client.post(path, item).body) end else required_parameters&.each do |p| if [p].nil? puts "Error: #{p} is required." exit 1 end end puts JSON.dump(client.post(path, ).body) end end |
#path ⇒ Object
7 8 9 |
# File 'lib/ralph/cli/commands/post.rb', line 7 def path self.class.path end |
#path=(v) ⇒ Object
10 11 12 |
# File 'lib/ralph/cli/commands/post.rb', line 10 def path=(v) self.class.path = v end |
#required_parameters ⇒ Object
14 15 16 |
# File 'lib/ralph/cli/commands/post.rb', line 14 def required_parameters self.class.required_parameters end |
#required_parameters=(v) ⇒ Object
18 19 20 |
# File 'lib/ralph/cli/commands/post.rb', line 18 def required_parameters=(v) self.class.required_parameters = v end |