Class: Synaptic::Neuron
- Inherits:
-
Object
- Object
- Synaptic::Neuron
- Defined in:
- lib/synaptic/neuron.rb
Instance Method Summary collapse
-
#initialize(model, options) ⇒ Neuron
constructor
A new instance of Neuron.
- #synapses ⇒ Object
Constructor Details
#initialize(model, options) ⇒ Neuron
Returns a new instance of Neuron.
3 4 5 6 7 8 |
# File 'lib/synaptic/neuron.rb', line 3 def initialize model, @model = model @white_list = [:only] || [] @black_list = [:except] || [] end |
Instance Method Details
#synapses ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/synaptic/neuron.rb', line 10 def synapses @synapses ||= begin synapses = @model.reflect_on_all_associations synapses.select!{ |x| @white_list.include?( x.name ) } unless @white_list.empty? synapses.reject!{ |x| @black_list.include?( x.name ) } unless @black_list.empty? synapses end end |