Code Monkey home page Code Monkey logo

schema_plus_columns's Introduction

Gem Version Build Status Coverage Status Dependency Status

SchemaPlus::Columns

SchemaPlus::Columns adds some useful accessors the objects returned by ActiveRecord's Model.columns database introspection query.

SchemaPlus::Columns is part of the SchemaPlus family of Ruby on Rails extension gems.

Installation

As usual:

gem "schema_plus_columns"                # in a Gemfile
gem.add_dependency "schema_plus_columns" # in a .gemspec

Usage

SchemaPlus::Columns makes these accessors available:

column.indexes

Returns a list of index definitions for each index that refers to this column. Returns an empty list if there are no such indexes.

column.unique?

Returns true if the column is in a unique index.

column.unique_scope

If the column is in a unique index, returns a list of names of other columns in the index. Returns an empty list if it's a single-column index. Returns nil if the column is not in a unique index.

column.case_sensitive?

Returns true if the column is in one or more indexes that are case sensitive. Requires the index definitions to respond to :case_sensitive? -- i.e. Only works with schema_plus_pg_indexes having been loaded.

column.required_on

Returns an indicator of the circumstance in which the column must have a value:

  • nil If the column may be null
  • :save If the column has no default value
  • :update Otherwise

Compatibility

SchemaPlus::Columns is tested on:

  • ruby 2.3.1 with activerecord 4.2, using mysql2, sqlite3 or postgresql
  • ruby 2.3.1 with activerecord 5.0, using mysql2, sqlite3 or postgresql

History

  • 0.1.3 - AR 5.0 Support
  • 0.1.2 - Missing require
  • 0.1.1 - Explicit gem dependencies
  • 0.1.0 - Initial release, extracted from SchemaPlus 1.x

Development & Testing

Are you interested in contributing to SchemaPlus::Columns? Thanks! Please follow the standard protocol: fork, feature branch, develop, push, and issue pull request.

Some things to know about to help you develop and test:

  • schema_dev: SchemaPlus::Columns uses schema_dev to facilitate running rspec tests on the matrix of ruby, activerecord, and database versions that the gem supports, both locally and on travis-ci

    To to run rspec locally on the full matrix, do:

      $ schema_dev bundle install
      $ schema_dev rspec
    

    You can also run on just one configuration at a time; For info, see schema_dev --help or the schema_dev README.

    The matrix of configurations is specified in schema_dev.yml in the project root.

  • schema_plus_core: SchemaPlus::Columns uses the SchemaPlus::Core API that provides middleware callback stacks to make it easy to extend ActiveRecord's behavior. If that API is missing something you need for your contribution, please head over to schema_plus_core and open an issue or pull request.
  • schema_monkey: SchemaPlus::Columns is implemented as a schema_monkey client, using schema_monkey's convention-based protocols for extending ActiveRecord and using middleware stacks.

schema_plus_columns's People

Contributors

ronen avatar boazy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.