Class: SimpleAMS::Document::Relations
- Inherits:
-
Object
- Object
- SimpleAMS::Document::Relations
- Includes:
- Enumerable
- Defined in:
- lib/simple_ams/document/relations.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #available ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(options, relations) ⇒ Relations
constructor
A new instance of Relations.
Constructor Details
#initialize(options, relations) ⇒ Relations
Returns a new instance of Relations.
8 9 10 11 12 13 |
# File 'lib/simple_ams/document/relations.rb', line 8 def initialize(, relations) @options = @relations = relations @serializer = .serializer @resource = .resource end |
Instance Method Details
#[](key) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/simple_ams/document/relations.rb', line 15 def [](key) found = relations.find{|relation| relation.name == key} return nil unless found return relation_for(found) end |
#available ⇒ Object
36 37 38 39 40 |
# File 'lib/simple_ams/document/relations.rb', line 36 def available return @available ||= [] if relations.available.empty? @available ||= self.class.new(, relations.available) end |
#each(&block) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/simple_ams/document/relations.rb', line 22 def each(&block) return enum_for(:each) unless block_given? relations.each{ |relation| yield relation_for(relation) } self end |
#empty? ⇒ Boolean
32 33 34 |
# File 'lib/simple_ams/document/relations.rb', line 32 def empty? count == 0 end |