Brick House was made to be used in conjunction with brick layer. Brick House provides an interface to your Brick Layer application. To use Brick House you can include it in the same application as your Brick Layer gem or you can add it to another application and consume the Brick Layer data from that location. The idea is that you don't have to use Brick House if you just want to consume data, but the option is there.
Just create a template in the 'views/templates' directory and match it's name to the data set you want at the endpoint of the route and voila - it shoud use that template.
Brick House pulls in the routing data from your Brick Layer endpoint and automatically integrates those defined routes into your application.
There is a search object created for easy integration with the search feature of the brick house server.
Install and Configuration
This gem works with brick layer gem @ github.com/rmcafee/brick_layer
Within the application in which you want to consume Brick Layer data:
# Gemfile gem 'brick_house'
You also want to create an initialzer file of some sort to set your configuration data.
# /config/initializers/brick_house_init.rb BrickHouse.brick_layer_endpoint = "yourendpoint:port"
# /config/initializers/brick_house_init.rb BrickHouse.brick_layer_endpoint = "127.0.0.1:3000"
If you want to use Brick House within the same application as brick layer, just don't create an endpoint. This endpoint is obviously just an example. Now you should be ready to roll.
Once you have your route and endpoints(remember this is optional) setup you can just create a 'templates' directory in your 'app/views' directory. This is where you drop your templates into. Your HTML request to the Brick House app should automatically take to you to the dataset based on the page and it'll try to use the template named after the data set the conventional Rails manner.
### IN BRICK LAYER ### # This is in /app/models/page_data_set/homepage.rb # class PageDataSets::Homepage field :my_data_1 field :my_data_2 end # You create a page using the Brick Layer Admin and set it to this data set template. # Let's assume you set the homepage to use this data set template. ### IN BRICK HOUSE ### # After you set the endpoint to your Brick Layer app you create a matching name template in the proper directory. # When someone makes a request matching the path to your data set set in Brick Layer a template will be rendered and # a @data_set object will be made available. # This is in /app/vew/templates/homepage.html.erb # <h1><%= @data_set.title %></h1> <p><%= @data_set.my_data_1 %></p> <p><%= @data_set.my_data_2 %></p>
That's all you need and you are rolling. You have access to the data but you can still develop the application like normal.
Standalone Data Sets
“Sooooo.…. what if I want to pull the data set from Brick Layer that isn't page specific. The Standalone Data Sets if you will.'”
If you are pulling data across the wire and you need access to that standalone data set you can easily do that.
Example: You want to pull the data for a brick layer "Employee" data set. ### IN BRICK LAYER ### # This is in /app/models/employee.rb # class Employee < BrickLayer::DataSet field :first_name field :last_name end ### IN BRICK HOUSE ### # To get a list of employees @employees = BrickHouse::DataSet.get("/employees") # To get a specific employee @employees = BrickHouse::DataSet.get("/employees/[employee-id]")
This actually works with page data sets as well. You just would call it differently.
@about_data = BrickHouse::PageDataSet.get("/about-us")
You can pull the routes from brick layer by using the method: