module Glass::Config

Attributes

app_name[RW]
format[RW]
models[RW]
mounted_at[RW]
registry[RW]
routes[RW]

Public Class Methods

capitalize_singularize(model) click to toggle source
# File lib/glass/config.rb, line 29
def capitalize_singularize(model)
  model.capitalize.singularize
end
create_routes(model) click to toggle source
# File lib/glass/config.rb, line 33
def create_routes(model)
  model_scope = pluralize_downcase(model)
  model_name = capitalize_singularize(model)

  return_routes(model_name, model_scope)
end
models_with_routes() click to toggle source
# File lib/glass/config.rb, line 19
def models_with_routes
  @models.each do |model|
    @routes[model.downcase.to_sym] = create_routes(model)
  end
end
pluralize_downcase(model) click to toggle source
# File lib/glass/config.rb, line 25
def pluralize_downcase(model)
  model.pluralize.downcase
end
reset() click to toggle source
# File lib/glass/config.rb, line 11
def reset
  @app_name = ''
  @mounted_at = '/api'
  @models = []
  @format = :json
  @routes = {}
end
return_routes(model_name, model_scope) click to toggle source
# File lib/glass/config.rb, line 40
def return_routes(model_name, model_scope)
  return {
      "index"   => { "type" => "get",   "path" => "/#{model_scope}"      },
      "show"    => { "type" => "get",   "path" => "/#{model_scope}/:id"  },
      "create"  => { "type" => "post",  "path" => "/#{model_scope}"      },
      "update"  => { "type" => "put",   "path" => "/#{model_scope}/:id"  },
      "destroy" => { "type" => "delete","path" => "/#{model_scope}/:id"  } }
end
setup() click to toggle source
# File lib/glass/config.rb, line 49
def setup
  models_with_routes
end