lib/jflow/activity/definition.rb in jflow-0.3.6 vs lib/jflow/activity/definition.rb in jflow-0.4.0
- old
+ new
@@ -1,18 +1,23 @@
module JFlow
module Activity
class Definition
- DEFAULT_OPTIONS = {}
+ DEFAULT_OPTIONS = {
+ :exceptions_to_exclude => []
+ }
+ REGISTRATION_OPTIONS = [:version, :domain, :name, :default_task_list]
+
OPTIONS_VALIDATOR = {
:version => "string",
:domain => "string",
:name => "string",
:default_task_list => {
:name => "string"
- }
+ },
+ :exceptions_to_exclude => 'array'
}
attr_reader :options, :klass
# Possible options are :
@@ -36,11 +41,11 @@
register_activity unless registered?
add_to_activity_mapping
end
def register_activity
- JFlow.configuration.swf_client.register_activity_type(options)
+ JFlow.configuration.swf_client.register_activity_type(registration_options)
JFlow.configuration.logger.info "Activity #{name} was registered successfuly"
end
def add_to_activity_mapping
JFlow.configuration.activity_map.add_activity(name, options[:version], klass, options)
@@ -75,13 +80,19 @@
return false
end
private
+ def registration_options
+ REGISTRATION_OPTIONS.each_with_object({}) do |key, hash|
+ hash[key] = @options[key]
+ end
+ end
+
def validate_activity!
validator = HashValidator.validate(@options, OPTIONS_VALIDATOR)
raise "Activity #{options[:name]}definition is invalid! #{validator.errors}" unless validator.valid?
end
end
end
-end
\ No newline at end of file
+end