Module: Pincushion::RootModuleMethods
- Includes:
- Plugins
- Defined in:
- lib/pincushion.rb
Instance Attribute Summary collapse
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
Attributes included from Plugins
Instance Method Summary collapse
Methods included from Plugins
Instance Attribute Details
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
36 37 38 |
# File 'lib/pincushion.rb', line 36 def identifiers @identifiers end |
Instance Method Details
#find(identifier) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/pincushion.rb', line 44 def find(identifier) unless identifiers.key?(identifier) fail MissingIdentifierError, "Can't find model #{identifier.inspect}" end identifiers[identifier].new(identifier) end |
#predicates(*preds) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/pincushion.rb', line 52 def predicates(*preds) return (@predicates || Set.new) if preds.empty? fail "Predicates can't be changed after initialization" if @predicates @predicates = Set.new(preds) is_not(*@predicates) @predicates.each do |predicate| alias_method(:"is_#{predicate}?", :"#{predicate}?") end end |
#rows ⇒ Object
38 39 40 41 42 |
# File 'lib/pincushion.rb', line 38 def rows identifiers.map do |id, cls| { identifier: id }.merge(cls.new(id).all_predicates_hash) end end |