Module: YiffSpace::Concerns::CurrentMethods::ClassMethods
- Defined in:
- lib/yiffspace/concerns/current_methods.rb
Instance Method Summary collapse
- #create_with_current ⇒ Object
- #create_with_current! ⇒ Object
- #new_with_current ⇒ Object
- #search_current(params) ⇒ Object
- #with_current(instance, method, *args) ⇒ Object
Instance Method Details
#create_with_current ⇒ Object
28 29 30 |
# File 'lib/yiffspace/concerns/current_methods.rb', line 28 def create_with_current(...) with_current(self, :create, ...) end |
#create_with_current! ⇒ Object
32 33 34 |
# File 'lib/yiffspace/concerns/current_methods.rb', line 32 def create_with_current!(...) with_current(self, :create!, ...) end |
#new_with_current ⇒ Object
24 25 26 |
# File 'lib/yiffspace/concerns/current_methods.rb', line 24 def new_with_current(...) with_current(self, :new, ...) end |
#search_current(params) ⇒ Object
9 10 11 |
# File 'lib/yiffspace/concerns/current_methods.rb', line 9 def search_current(params, ...) search(params, YiffSpace.config.current_class.user, ...) end |
#with_current(instance, method, *args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/yiffspace/concerns/current_methods.rb', line 13 def with_current(instance, method, *args, **, &) attr = args.grep(Symbol) other = args - attr hashes = other.grep(Hash) params = other.grep(ActionController::Parameters) other -= hashes + params other.compact_blank! = [attr.index_with(YiffSpace.config.current_class.user), *hashes, *params.map(&:to_hash)].inject(:merge) instance.send(method, *other, **, **, &) end |