Class: SimpleAMS::Options::Relations
- Inherits:
-
Array
- Object
- Array
- SimpleAMS::Options::Relations
- Defined in:
- lib/simple_ams/options/relations.rb
Defined Under Namespace
Classes: Relation
Instance Attribute Summary collapse
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#relations ⇒ Object
readonly
Returns the value of attribute relations.
Instance Method Summary collapse
- #available ⇒ Object
-
#initialize(relations, includes = nil) ⇒ Relations
constructor
A new instance of Relations.
Constructor Details
#initialize(relations, includes = nil) ⇒ Relations
Returns a new instance of Relations.
7 8 9 10 11 12 |
# File 'lib/simple_ams/options/relations.rb', line 7 def initialize(relations, includes = nil) @relations = relations @includes = includes super(relations.map { |rel| Relations::Relation.new(*rel) }) end |
Instance Attribute Details
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
5 6 7 |
# File 'lib/simple_ams/options/relations.rb', line 5 def includes @includes end |
#relations ⇒ Object (readonly)
Returns the value of attribute relations.
5 6 7 |
# File 'lib/simple_ams/options/relations.rb', line 5 def relations @relations end |
Instance Method Details
#available ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/simple_ams/options/relations.rb', line 14 def available return @available ||= self if includes.nil? return @available ||= [] if includes.empty? @available ||= self.select do |relation| includes.include?(relation.name) end end |