Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added factories for all validations. Configuration factories can now …
…only be set once.
- Loading branch information
1 parent
9fc654a
commit b160f27
Showing
18 changed files
with
244 additions
and
131 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* test validation factories |
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
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 |
---|---|---|
@@ -1,4 +1,14 @@ | ||
module Errapi::Plugins | ||
class Base | ||
|
||
def self.plugin_name name = nil | ||
name ? @name = name : @name | ||
end | ||
|
||
def name | ||
self.class.name | ||
end | ||
end | ||
end | ||
|
||
Dir[File.join File.dirname(__FILE__), File.basename(__FILE__, '.*'), '*.rb'].each{ |lib| require lib } |
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 |
---|---|---|
@@ -1,29 +1,29 @@ | ||
module Errapi | ||
class Plugins::Location | ||
class << self | ||
attr_writer :config | ||
attr_accessor :camelize | ||
module Errapi::Plugins | ||
class Location < Base | ||
plugin_name :location | ||
|
||
def serialize_error error, serialized | ||
if error.location && error.location.respond_to?(:serialize) | ||
attr_writer :config | ||
attr_accessor :camelize | ||
|
||
serialized_location = error.location.serialize | ||
unless serialized_location.nil? | ||
serialized[:location] = serialized_location | ||
serialized[location_type_key] = error.location.location_type if error.location.respond_to? :location_type | ||
end | ||
def serialize_error error, serialized | ||
if error.location && error.location.respond_to?(:serialize) | ||
|
||
serialized_location = error.location.serialize | ||
unless serialized_location.nil? | ||
serialized[:location] = serialized_location | ||
serialized[location_type_key] = error.location.location_type if error.location.respond_to? :location_type | ||
end | ||
end | ||
end | ||
|
||
private | ||
private | ||
|
||
def location_type_key | ||
camelize? ? :locationType : :location_type | ||
end | ||
def location_type_key | ||
camelize? ? :locationType : :location_type | ||
end | ||
|
||
def camelize? | ||
@camelize.nil? ? @config.options.camelize : @camelize | ||
end | ||
def camelize? | ||
@camelize.nil? ? @config.options.camelize : @camelize | ||
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
module Errapi | ||
class Plugins::Reason | ||
class << self | ||
attr_writer :config | ||
attr_accessor :camelize | ||
module Errapi::Plugins | ||
class Reason < Base | ||
plugin_name :reason | ||
|
||
def serialize_error error, serialized | ||
serialized[:reason] = serialized_reason error | ||
end | ||
attr_writer :config | ||
attr_accessor :camelize | ||
|
||
private | ||
def serialize_error error, serialized | ||
serialized[:reason] = serialized_reason error | ||
end | ||
|
||
private | ||
|
||
def serialized_reason error | ||
camelize? ? Utils.camelize(error.reason.to_s).to_sym : error.reason | ||
end | ||
def serialized_reason error | ||
camelize? ? Utils.camelize(error.reason.to_s).to_sym : error.reason | ||
end | ||
|
||
def camelize? | ||
@camelize.nil? ? @config.options.camelize : @camelize | ||
end | ||
def camelize? | ||
@camelize.nil? ? @config.options.camelize : @camelize | ||
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
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
Oops, something went wrong.