Class: Husky::DataSource::MemoryRelation
- Inherits:
-
Object
- Object
- Husky::DataSource::MemoryRelation
- Includes:
- Enumerable
- Defined in:
- lib/husky/data_source.rb
Instance Attribute Summary collapse
-
#caller ⇒ Object
readonly
Returns the value of attribute caller.
-
#receiving_class ⇒ Object
readonly
Returns the value of attribute receiving_class.
-
#set ⇒ Object
readonly
Returns the value of attribute set.
Instance Method Summary collapse
- #caller_id ⇒ Object
- #each ⇒ Object
-
#initialize(set, caller, receiving_class) ⇒ MemoryRelation
constructor
A new instance of MemoryRelation.
- #new(attributes) ⇒ Object
Constructor Details
#initialize(set, caller, receiving_class) ⇒ MemoryRelation
Returns a new instance of MemoryRelation.
43 44 45 46 47 |
# File 'lib/husky/data_source.rb', line 43 def initialize(set, caller, receiving_class) @set = set @caller = caller @receiving_class = receiving_class end |
Instance Attribute Details
#caller ⇒ Object (readonly)
Returns the value of attribute caller.
41 42 43 |
# File 'lib/husky/data_source.rb', line 41 def caller @caller end |
#receiving_class ⇒ Object (readonly)
Returns the value of attribute receiving_class.
41 42 43 |
# File 'lib/husky/data_source.rb', line 41 def receiving_class @receiving_class end |
#set ⇒ Object (readonly)
Returns the value of attribute set.
41 42 43 |
# File 'lib/husky/data_source.rb', line 41 def set @set end |
Instance Method Details
#caller_id ⇒ Object
59 60 61 |
# File 'lib/husky/data_source.rb', line 59 def caller_id "#{caller.class.to_s.split('::').last.downcase}_id".to_sym end |
#each ⇒ Object
49 50 51 |
# File 'lib/husky/data_source.rb', line 49 def each set.map { |item| yield item } end |
#new(attributes) ⇒ Object
53 54 55 56 57 |
# File 'lib/husky/data_source.rb', line 53 def new(attributes) attrs = attributes attrs[caller_id] = caller.id receiving_class.new(attrs) end |