Qualia
Qualia is a light Ruby controller & view framework (MVC) that reproduces some of the core functionality provided by Rails. Qualia also implements a basic Object-relational mapping tool (ORM) mimicking the standard ActiveRecord services using quale.
Demo
bundle install
cd qualia/sample
ruby app/sample.rb
Usage
Views & Controllers
Classes that extend Qualia's ControllerBase
have access to the following methods:
render(template)
- Render a specific viewrender_content(content_data, content_type)
- Detailed renderredirect_to(url)
session
- Add key-value pairs to thesession
hash to write data to cookies.flash
- Key-value pairs persist through to the next sessionflash.now
- Key-value pairs only live for the current session (1 response cycle).protect_from_forgery
- Make use of CSRF protection by addingprotect_from_forgery
to any controller to force Qualia to ensure that form data includes a validated authenticity token.
ORM
Qualia::SQLObject
is a lightweight version of ActiveRecord::Base that implements common CRUD methods with little overhead.
Query methods include:
::all
::find
::where
::destroy_all
#insert
#update
#destroy
Associations between objects are class methods. For example:
class Photo < ApplicationRecord
belongs_to :album
has_one_through :author,
:album,
:user_id
end
class Album < ApplicationRecord
belongs_to :author, foreign_key: :user_id, class_name: :User
has_many :photos
end
class User < ApplicationRecord
has_many :albums
end
Future Plans
- Implement strong parameters (
require
,permit
) - Enable eager loading / pre-fetching
- Enable more complex
where
queries - Add validators & validations
- Thor command-line interface
- RubyGems integration