June 2017
Beginner
330 pages
7h 30m
English
To see what a private method looks like, let's take a look at a real-world Ruby on Rails project that I built:
class InventoriesController < ApplicationController # Public methods not shown for brevity private def set_inventory @inventory = Inventory.find(params[:id]) end def inventory_params params.require(:inventory).permit(:title, :qty, :ticket_id) endend
As you can see, in Ruby, we designate private methods using the private word above the list of methods. Usually, private methods are placed at the end of the file after all the public methods. Both private methods shown here provide functionality specific to the InventoriesController class, and to no other.
Going back to our code example, that is the ApiConnector ...
Read now
Unlock full access