Module: MagicResource
- Defined in:
- lib/magic-resource.rb,
lib/magic-resource/helper.rb,
lib/magic-resource/version.rb,
lib/magic-resource/container.rb,
lib/magic-resource/controller.rb,
lib/magic-resource/path_with_http_verb.rb,
lib/generators/magic_resource/install_generator.rb
Defined Under Namespace
Modules: Controller, Generators, Helper
Classes: Container, PathWithHttpVerb
Constant Summary
collapse
- MAGIC_PARAMETERS =
%w(
force_resource_name_definition
assert_resource_name_in_controller
disable_content_for_helper
).freeze
- MAGIC_VALID_VALUES =
[false, :by_exception, :by_warning].freeze
- VERSION =
'0.0.4'.freeze
- @@default_context =
:crud
- @@default_form_type =
:simple
Class Method Summary
collapse
Class Method Details
.assert_restriction(restriction_type, message) ⇒ Object
69
70
71
72
73
74
75
|
# File 'lib/magic-resource.rb', line 69
def self.assert_restriction(restriction_type, message)
message.prepend('MagicResource: ')
case class_variable_get(:"@@#{restriction_type}")
when :by_exception then raise(message)
when :by_warning then logger.warn(message)
end
end
|
.full_magic! ⇒ Object
55
56
57
|
# File 'lib/magic-resource.rb', line 55
def self.full_magic!
set_all_magic_parameters(false)
end
|
.logger ⇒ Object
65
66
67
|
# File 'lib/magic-resource.rb', line 65
def self.logger
::Rails.logger
end
|
.no_magic ⇒ Object
47
48
49
|
# File 'lib/magic-resource.rb', line 47
def self.no_magic
set_all_magic_parameters(:by_exception)
end
|
.set_all_magic_parameters(value) ⇒ Object
59
60
61
62
63
|
# File 'lib/magic-resource.rb', line 59
def self.set_all_magic_parameters(value)
MAGIC_PARAMETERS.each do |param|
public_send(:"#{param}=", value)
end
end
|
.setup {|_self| ... } ⇒ Object
43
44
45
|
# File 'lib/magic-resource.rb', line 43
def self.setup
yield self
end
|
.try_magic? ⇒ Boolean
51
52
53
|
# File 'lib/magic-resource.rb', line 51
def self.try_magic?
set_all_magic_parameters(:by_warning)
end
|