-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Sabisu | ||
module Generators | ||
class InstallGenerator < Rails::Generators::Base | ||
source_root File.expand_path("../templates", __FILE__) | ||
|
||
desc "Creates a Sabisu initializer in your application" | ||
|
||
def copy_initializer | ||
template "sabisu.rb", "config/initializers/sabisu.rb" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Use this module to configure the sabisu available options | ||
|
||
Sabisu.setup do |config| | ||
|
||
# Base uri for posting the | ||
# config.base_api_uri = nil | ||
|
||
# Ignored attributes for building the forms | ||
# config.ignored_attributes = %w{ created_at updated_at id } | ||
|
||
# HTTP methods | ||
# config.http_methods = %w{ GET POST PUT DELETE PATCH } | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,36 @@ | ||
require "sabisu/version" | ||
|
||
module Sabisu | ||
# Your code goes here... | ||
|
||
# We ignore some attribues that might cause a collision between models | ||
@@default_ignored_attributes = %w{ created_at updated_at id } | ||
|
||
# We append the extra attributes you want to ignore to the default ones | ||
mattr_accessor :ignored_attributes | ||
@@ignored_attributes = @@ignored_attributes.to_a + @@default_ignored_attributes | ||
|
||
# Base api uri for the endpoints | ||
mattr_accessor :base_api_uri | ||
@@base_api_uri = nil | ||
|
||
# HTTP methods for the api | ||
@@default_http_methods = %w{ GET POST PUT DELETE PATCH } | ||
|
||
mattr_accessor :http_methods | ||
@@http_methods = @@http_methods.to_a + @@default_http_methods | ||
|
||
@@configured = false | ||
|
||
def self.configured? #:nodoc: | ||
@@configured | ||
end | ||
|
||
#Method to configure sabisu | ||
def self.setup | ||
@@configured = true | ||
yield self | ||
end | ||
|
||
end | ||
|
||
require 'sabisu/railtie' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'rails/railtie' | ||
|
||
module Sabisu | ||
class Railtie < Rails::Railtie | ||
config.eager_load_namespaces << Sabisu | ||
|
||
config.after_initialize do | ||
unless Sabisu.configured? | ||
warn '[Sabisu] Sabisu is not configured in the application and will use the default values.' + | ||
' We recommend you to check the file just created with the installer and setup it up.' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters