Module: Flounder::Helpers::Entity
- Included in:
- Query::Base, Relation
- Defined in:
- lib/flounder/helpers/entity.rb
Overview
Helper module that helps with entity resolution. To include this module in a class, you need to provide the following two methods:
* has_entity?(sym) -> Boolean
Decides if a given symbol can be converted into an entity
* resolve_entity(sym) -> Entity
Resolves an entity from a symbol name.
Instance Method Summary collapse
Instance Method Details
#convert_to_entity(something) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/flounder/helpers/entity.rb', line 17 def convert_to_entity something case something when Flounder::Entity, Flounder::EntityAlias return something when Symbol return resolve_entity(something) else fail "Not entity-like - yet! (#{something.inspect})" end end |
#entity_like?(something) ⇒ Boolean
12 13 14 15 16 |
# File 'lib/flounder/helpers/entity.rb', line 12 def entity_like? something something.kind_of?(Flounder::Entity) || something.kind_of?(Flounder::EntityAlias) || something.kind_of?(Symbol) && has_entity?(something) end |