Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/concerned/module_ext.rb
Instance Method Summary collapse
- #concerned_with(*concerns) ⇒ Object
- #include_concerns(*concerns) ⇒ Object (also: #include_concern)
- #include_shared_concerns(*concerns) ⇒ Object (also: #include_shared_concern, #include_shared)
- #shared_concerns(*concerns) ⇒ Object (also: #shared_concern)
Instance Method Details
#concerned_with(*concerns) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/concerned/module_ext.rb', line 2 def concerned_with(*concerns) = concerns. concerns.flatten.each do |concern| next if concern.blank? require_concern name, concern end shared_concerns([[:shared]].flatten.compact) end |
#include_concerns(*concerns) ⇒ Object Also known as: include_concern
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/concerned/module_ext.rb', line 18 def include_concerns(*concerns) = concerns. scope_name = [:for] || [:from] || name concerns.flatten.each do |concern| next if concern.blank? require_concern scope_name, concern concern_ns ||= [scope_name.to_s.camelize, concern.to_s.camelize].join('::') self.send :include, concern_ns.constantize if Concerned.extend_enabled? begin self.extend [concern_ns, 'ClassMethods'].join('::').constantize rescue end end end class_eval do self.my_concerns += concerns.flatten if self.respond_to?(:my_concerns) end include_shared_concerns([[:shared]].flatten.compact) end |
#include_shared_concerns(*concerns) ⇒ Object Also known as: ,
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/concerned/module_ext.rb', line 44 def include_shared_concerns(*concerns) concerns.flatten.each do |concern| next if concern.blank? Concerned.require_shared concern concern_ns = concern.to_s.camelize self.send :include, Concerned.shared_const(concern_ns) if Concerned.extend_enabled? begin self.extend [concern_ns, 'ClassMethods'].join('::').constantize rescue end end end class_eval do self.my_shared_concerns += concerns.flatten if self.respond_to?(:my_shared_concerns) end end |
#shared_concerns(*concerns) ⇒ Object Also known as:
11 12 13 14 15 16 |
# File 'lib/concerned/module_ext.rb', line 11 def shared_concerns(*concerns) concerns.flatten.each do |concern| next if concern.blank? Concerned.require_shared concern end end |