lib/surrounded/context.rb in surrounded-0.9.11 vs lib/surrounded/context.rb in surrounded-1.0.0

- old
+ new

@@ -51,11 +51,11 @@ # Set the default type of implementation for role method for an individual context. def default_role_type=(type) @default_role_type = type end - + # Provide the ability to create access control methods for your triggers. def protect_triggers; self.extend(::Surrounded::AccessControl); end # Automatically create class methods for each trigger method. def shortcut_triggers; self.extend(::Surrounded::Shortcuts); end @@ -66,11 +66,11 @@ # === Utility shortcuts def role_const_defined?(name) const_defined?(name, false) end - + # Set a named constant and make it private def private_const_set(name, const) unless role_const_defined?(name) const = const_set(name, const) private_constant name.to_sym @@ -117,15 +117,17 @@ # Return a Set of all defined triggers def triggers self.class.triggers end - def rebind(options_hash) + def rebind(**options_hash) clear_instance_variables - initialize(**options_hash) - rescue ArgumentError - initialize(*options_hash.values) + begin + initialize(options_hash) + rescue ArgumentError + initialize(*options_hash.values) + end self end private @@ -191,11 +193,11 @@ def apply_class_behavior(klass, obj) wrapper_name = wrap_methods.find{|meth| klass.respond_to?(meth) } return obj if !wrapper_name klass.method(wrapper_name).call(obj) end - + def remove_behavior(role, behavior, object) if behavior && role_const_defined?(behavior) remover_name = (module_removal_methods + unwrap_methods).find do |meth| object.respond_to?(meth) end @@ -304,6 +306,6 @@ def to_sym @string.to_sym end end end -end \ No newline at end of file +end