0.0
No commit activity in last 3 years
No release in over 3 years
an ActiveRecord/Sequel style class for static reference data
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.9
~> 10.0
 Project Readme

ArrayModel

ArrayModel is a class to create ActiveRecord / Sequel style models from simple arrays and hashes. This is useful for integrating simple reference data into an application without having to create many small tables that will never change.

As data should be never change while the application is running, the model objects that are created are read only. The data can come either from a constant in the ruby script itself, or from the filesystem as a YAML or JSON file.

Usage

Example:

USERS = [
    { name: 'Nathan', year: 1984 }, 
    { name: 'Dave', year: 1987 }
]

class User < ArrayModel
    model_data USERS
    attr_model_reader :name
    attr_model_reader :year

    def age
        Time.now.year - year
    end
end

User[0].age # => 32
User[1].name # => "Dave"