Module: WellFormed::WithUser
- Included in:
- ActionForm, NestedForm, ResourceForm, Struct
- Defined in:
- lib/well_formed/with_user.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#_build_nested_form(form_class, resource, attrs = {}) ⇒ Object
Instantiates a nested form with the current user.
- #initialize(resource, user, params = {}) ⇒ Object
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
31 32 33 |
# File 'lib/well_formed/with_user.rb', line 31 def user @user end |
Class Method Details
.included(base) ⇒ Object
16 17 18 |
# File 'lib/well_formed/with_user.rb', line 16 def self.included(base) raise ArgumentError, "#{name} must be prepended, not included. Use `prepend #{name}` instead." end |
.prepended(base) ⇒ Object
11 12 13 14 |
# File 'lib/well_formed/with_user.rb', line 11 def self.prepended(base) base.extend(ClassMethods) @extensions.each { |mod| base.include(mod) } end |
.register_extension(mod) ⇒ Object
7 8 9 |
# File 'lib/well_formed/with_user.rb', line 7 def self.register_extension(mod) @extensions << mod end |
Instance Method Details
#_build_nested_form(form_class, resource, attrs = {}) ⇒ Object
Instantiates a nested form with the current user.
34 35 36 |
# File 'lib/well_formed/with_user.rb', line 34 def _build_nested_form(form_class, resource, attrs = {}) form_class.new(resource, user, attrs) end |
#initialize(resource, user, params = {}) ⇒ Object
38 39 40 41 |
# File 'lib/well_formed/with_user.rb', line 38 def initialize(resource, user, params = {}) @user = user super(resource, params) end |