0.01
The project is in a healthy, maintained state
UmbrellioUtils is collection of utility classes and helpers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1
 Project Readme

Umbrellio Utils Gem Version Coverage Status

Installation

Add this line to your application's Gemfile:

gem "umbrellio-utils"

And then execute:

$ bundle install

Or install it yourself as:

$ gem install umbrellio-utils

Usage

Quick Start

You can use modules and classes directly by accessing modules and classes under namespace UmbrellioUtils. Or you can include UmbrellioUtils to other module with name you like.

# Direct using
UmbrellioUtils::Constants.get_class!(:object) #=> Object

# Aliasing to shorter name.

module Utils
  include UmbrellioUtils
end

Utils::Constants.get_class!(:object) #=> Object
Utils::Constants #=> UmbrellioUtils::Constants

Configuration

Some modules and classes are configurable. Here's the full list of settings and what they do:

  • store_table_name — table which is used by UmbrellioUtils::Store module. Defaults to :store
  • http_client_name — fiber-local variable name for http client instance in UmbrellioUtils::HTTPClient. Defaults to :application_httpclient

You can change config in two ways. Firstly, you can change values by accessing configuration directly. Secondly, you can use UmbrellioUtils::configure method which accepts a block.

# First method

UmbrellioUtils.config.store_table_name = :cool_name

# Second method

module Utils
  include UmbrellioUtils

  configure do |config|
    config.store_table_name = :cool_name
  end
end

Keep in mind that the config is common to all modules: if you use multiple modules that include UmbrellioUtils, then all modules will use the same configuration object.

Extension

You can extend module with you own project specific methods via UmbrellioUtils::extend_util!.

module Utils
  include UmbrellioUtils

  configure do |config|
    config.store_table_name = :cool_name
  end

  extend_util!(:Constants) do
    def useful_method
      "Just string"
    end
  end
end

Utils::Constants.useful_method #=> "Just string"

Or you can define methods in your module and then extend the desired module.

module MyHelpers
  def useful_method
    "Just string"
  end
end

module Utils
  include UmbrellioUtils

  extend_util!(:Constants) { extend MyHelpers }
end

Utils::Constants.useful_method #=> "Just string"

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/umbrellio/utils.

License

The gem is available as open source under the terms of the MIT License.

Authors

Created by Umbrellio's Ruby developers

Supported by Umbrellio