Sha256: ca9b0c35976cd04b7a22fc8fd64abe595456e86bd28b95b92c9065c36c8bd3ff

Contents?: true

Size: 705 Bytes

Versions: 2

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'neco'

# An example class for validation and main logic
# with block parameter.
class Foo
  include Neco::Command

  validates do |name:|
    name == 'Tama'
  end

  main do |name:|
    puts "Hello, #{name}!"
  end
end

Foo.call(name: 'Tama')
Foo.call(name: 'Pochi')
Foo.new.call(name: 'Tama')
Foo.new(name: 'Pochi').call

class Bar
  include Neco::Command

  main do |answer|
    puts "The ultimate answer is #{answer}"
  end
end

Bar.call(42)
Bar.new(42).call

class Buzz
  include Neco::Command

  main do |user:, params: nil|
    user.update(params)
    p "User is now #{user}"
  end
end

Buzz.new(user: {}).call(params: {name: 'Tama'})

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
neco-0.2.0 examples/command.rb
neco-0.1.0 examples/command.rb