0.01
No commit activity in last 3 years
No release in over 3 years
API for making APIs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

Don't use me yet - soon

FlexibleAPI

FlexibleAPI is a way to quickly build APIs inside of ActiveRecord models.

class Thing < ActiveRecord::Base

  define_request_level :simple do |level|
    level.fields :id, :name, :reverse_name
  end

  def reverse_name
    name.reverse
  end

end

That gives you the ability to do:

Thing.first.to_hash :simple # { :id => 1, :name => 'john', :reverse_name => 'nhoj' }

And if you use something like:

Thing.find_hash(:request_level => :simple)

Which will preselect only the fields that it needs, and if you do:

Thing.find_all_hash(:request_level => :simple)

It will preselect everything it needs to do those queries efficiently.

Defining request levels

define_request_level :simple do
  fields :one, :two, :three
  notation(:name, :requires => [:this, :that]) { self.something }
  requires :this
  scope :published
  scope :starts_with, 'a'
end

Nesting

define_request_level :complex do |level|
  level.fields :id, :name
  level.includes :association
end

FlexibleAPIServer

This is a way to expose FlexibleAPIs via a thin Sinatra server, which makes restful paths for all of the request levels that you create


License

MIT License. See attached