class Ribose::CLI::Commands::Space

Public Instance Methods

add() click to toggle source
# File lib/ribose/cli/commands/space.rb, line 27
def add
  space = Ribose::Space.create(symbolize_keys(options))
  say("New Space created! Id: " + space.id)
end
list() click to toggle source
# File lib/ribose/cli/commands/space.rb, line 8
def list
  say(build_output(list_user_spaces, options))
end
remove() click to toggle source
# File lib/ribose/cli/commands/space.rb, line 51
def remove
  remove_space(options)
  say("The Sapce has been removed!")
rescue
  say("Please provide a valid Space UUID")
end
show() click to toggle source
# File lib/ribose/cli/commands/space.rb, line 16
def show
  space = Ribose::Space.fetch(options[:space_id])
  say(build_resource_output(space, options))
end
update() click to toggle source
# File lib/ribose/cli/commands/space.rb, line 39
def update
  attributes = symbolize_keys(options)
  Ribose::Space.update(attributes.delete(:space_id), attributes)
  say("Your space has been updated!")
rescue Ribose::UnprocessableEntity
  say("Something went wrong!, please check required attributes")
end

Private Instance Methods

list_user_spaces() click to toggle source
# File lib/ribose/cli/commands/space.rb, line 60
def list_user_spaces
  @user_spaces ||= Ribose::Space.all
end
remove_space(attributes) click to toggle source
# File lib/ribose/cli/commands/space.rb, line 64
def remove_space(attributes)
  Ribose::Space.remove(
    attributes[:space_id],
    password_confirmation: attributes[:confirmation],
  )
end
table_field_names() click to toggle source

Single resource fields

# File lib/ribose/cli/commands/space.rb, line 80
def table_field_names
  %w(id name visibility active members_count role_name)
end
table_headers() click to toggle source
# File lib/ribose/cli/commands/space.rb, line 71
def table_headers
  ["ID", "Name", "Active?"]
end
table_rows(spaces) click to toggle source
# File lib/ribose/cli/commands/space.rb, line 75
def table_rows(spaces)
  spaces.map { |space| [space.id, space.name, space.active ] }
end