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.
44 45 46 47 48 |
# File 'lib/husky/data_source.rb', line 44 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.
42 43 44 |
# File 'lib/husky/data_source.rb', line 42 def caller @caller end |
#receiving_class ⇒ Object (readonly)
Returns the value of attribute receiving_class.
42 43 44 |
# File 'lib/husky/data_source.rb', line 42 def receiving_class @receiving_class end |
#set ⇒ Object (readonly)
Returns the value of attribute set.
42 43 44 |
# File 'lib/husky/data_source.rb', line 42 def set @set end |
Instance Method Details
#caller_id ⇒ Object
60 61 62 |
# File 'lib/husky/data_source.rb', line 60 def caller_id "#{caller.class.to_s.split('::').last.downcase}_id".to_sym end |
#each ⇒ Object
50 51 52 |
# File 'lib/husky/data_source.rb', line 50 def each set.map { |item| yield item } end |
#new(attributes) ⇒ Object
54 55 56 57 58 |
# File 'lib/husky/data_source.rb', line 54 def new(attributes) attrs = attributes attrs[caller_id] = caller.id receiving_class.new(attrs) end |