sardaukar / monomyth-engine

The Engine With A Thousand Faces

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MonomythEngine

The Engine With A Thousand Faces

This is a simple hack to have endpoints on your Rails app composed of other actions' output. For example, you might have

/endpoints/meh
be the combined output of 2 other actions in your app.

Quick setup

  1. Add the gem to your Gemfile, e.g.:
  gem 'monomyth_engine', github: 'sardaukar/monomyth-engine'
  1. Mount the engine on your routes file:
  mount MonomythEngine::Engine, at: '/endpoints'
  1. Add a config file (by default looks in 'config/facades.yml') following this scheme:
facades:
  one:
    users: 'users#index'
    posts:
      route: 'posts#latest'
      bottom: 5
    format: 'json'
  1. Restart app, go to
    /endpoints/one
    and observe as the output of the mentioned actions is aggregated into this one.

The config file is re-parsed on every endpoint hit, so no need to reload the app for changes to occur.

Optionally, you can have an initializer:

MonomythEngine.configure do |c|
  c.facade_file = 'config/facades.yml'
  c.default_format = :json # not really used
end

DO NOT USE THIS CODE IN PRODUCTION. It's not even tested, and is just a hack to learn more about Rails actions and routes!!!!!11

Developed as a hack-day toy for a hack day at New Bamboo.

This project rocks and uses MIT-LICENSE.

About

The Engine With A Thousand Faces

License:MIT License


Languages

Language:Ruby 87.3%Language:CSS 6.8%Language:JavaScript 5.9%