Module: Grape::Entity::DSL
- Defined in:
- lib/grape_entity/entity.rb
Overview
The Entity DSL allows you to mix entity functionality into your existing classes.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#entity(options = {}) ⇒ Object
Instantiates an entity version of this object.
Class Method Details
.included(base) ⇒ Object
51 52 53 54 55 |
# File 'lib/grape_entity/entity.rb', line 51 def self.included(base) base.extend ClassMethods ancestor_entity_class = base.ancestors.detect { |a| a.entity_class if a.respond_to?(:entity_class) } base.const_set(:Entity, Class.new(ancestor_entity_class || Grape::Entity)) unless const_defined?(:Entity) end |
Instance Method Details
#entity(options = {}) ⇒ Object
Instantiates an entity version of this object.
97 98 99 |
# File 'lib/grape_entity/entity.rb', line 97 def entity( = {}) self.class.entity_class.new(self, ) end |