Git Product home page Git Product logo

fake_id's Introduction

FakeId

github.com/trliner/fake_id

Usage

Defining fake ids

class SecretAgentAlias < ActiveRecord::Base
  include FakeId

  attr_accessible :document_type_id

  fake_ids_for :document_type, {
    :drivers_license => 1,
    :passport => 2
  }
end

Generated instance methods

alias = SecretAgentAlias.new(:document_type_id = 1)
alias.document_type
=> :drivers_license

alias.document_type = :passport
alias.document_type
=> :passport

alias.passport?
alias.passport
=> true

alias.drivers_license?
alias.drivers_license
=> false

Generated class methods

SecretAgentAlias.document_types
=> [:drivers_license, :passport]

SecretAgentAlias.document_type_mappings
=> {1=>:drivers_license, 2=>:passport}

SecretAgentAlias.lookup_document_type(1)
=> :drivers_license

SecretAgentAlias.lookup_document_type(:passport)
=> 1

Generated named scopes

SecretAgentAlias.drivers_license
SecretAgentAlias.not_passport
SecretAgentAlias.document_type_is(:drivers_license)
SecretAgentAlias.document_type_is_not(:passport)
SecretAgentAlias.document_type_in(:drivers_license, :passport)
SecretAgentAlias.document_type_not_in(:drivers_license, :passport)

fake_id's People

Contributors

trliner avatar

Stargazers

 avatar  avatar

Watchers

 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.