Project

menilite

0.01
Low commit activity in last 3 years
No release in over a year
This is isomorphic models for sharing between client side and server side.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 10.0

Runtime

 Project Readme

Menilite

CircleCI

An isomorphic web programming framework in Ruby.
Ruby codes also run on the client side by using Opalrb.

Installation

Add this line to your application's Gemfile:

gem 'menilite'

And then execute:

$ bundle

Or install it yourself as:

$ gem install menilite

How to use

You can generate the template project by Silica to get started.

$ gem install silica
$ silica new your-app
$ cd your-app
$ bundle install
$ bundle exec rackup

Model definition

class User < Menilite::Model
    field :name
    field :password
end

Model definition is shared from the client side (compiled by Opal) and the server side (in MRI).
In this tiny example, User model has two string fields (name and password).
Field has a type and the type is set string as default.
You can specify another type by the following way, for example.

field :active, :boolean

Action

class User < Menilite::Model
  action :signup, save: true do |password|
    self.password = BCrypt::Password.create(password)
  end
end

Models can have actions. The action is executed on the server side and the client code call the action as a method.

on the client side

user = User.new(name: 'youchan')
user.auth('topsecret')

Controller

Controllers can have actions too.

class ApplicationController < Menilite::Controller
  action :login do |username, password|
    user = User.find(name: username)
    if user && user.auth(password)
      session[:user_id] = user.id
    else
      raise 'login failed'
    end
  end
end

The action of Controller is defined as a class method on the client side.

ApplicationController.login('youchan', 'topsecret')