Module: IAmMe
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/i-am-me.rb
Instance Method Summary collapse
- #me ⇒ Object (also: #my)
- #set_me ⇒ Object
Instance Method Details
#me ⇒ Object Also known as: my
29 30 31 |
# File 'lib/i-am-me.rb', line 29 def me RequestStore[:me] end |
#set_me ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/i-am-me.rb', line 16 def set_me # before_actionフックによりset_meメソッドがコールされるコントローラは`me_is_a`メソッドがコールされたコントローラと同じとは限らないため、 # ancestorsを遡ってtype_of_meを探す。 type_of_me = nil self.class.ancestors.each do |ancestor| type_of_me = ancestor.instance_variable_get(:@type_of_me) break if type_of_me break if ancestor == ApplicationController end return unless respond_to?("current_#{type_of_me}") RequestStore[:me] = send("current_#{type_of_me}") end |