Module: Encore::Entity::Input::ExposedAttributes::ClassMethods
- Defined in:
- lib/encore/entity/input/exposed_attributes.rb
Instance Method Summary collapse
-
#expose(column, opts = {}) ⇒ Object
Declare a new exposed attribute.
-
#exposed_attribute?(attribute) ⇒ Boolean
Return whether an attribute is exposed by the entity.
-
#exposed_attributes ⇒ Object
Return a list of all exposed attributes.
-
#modifiable_attribute?(attribute) ⇒ Boolean
Return whether an attribute is exposed by the entity.
-
#modifiable_attributes ⇒ Object
Return a list of all attributes that can be modified.
Instance Method Details
#expose(column, opts = {}) ⇒ Object
Declare a new exposed attribute
9 10 11 12 |
# File 'lib/encore/entity/input/exposed_attributes.rb', line 9 def expose(column, opts = {}) @exposed_attributes ||= [] @exposed_attributes << Encore::Attribute.new(self, column.to_sym, opts) end |
#exposed_attribute?(attribute) ⇒ Boolean
Return whether an attribute is exposed by the entity
15 16 17 |
# File 'lib/encore/entity/input/exposed_attributes.rb', line 15 def exposed_attribute?(attribute) @exposed_attributes.detect { |a| attribute == a } end |
#exposed_attributes ⇒ Object
Return a list of all exposed attributes
25 26 27 |
# File 'lib/encore/entity/input/exposed_attributes.rb', line 25 def exposed_attributes @exposed_attributes end |
#modifiable_attribute?(attribute) ⇒ Boolean
Return whether an attribute is exposed by the entity
20 21 22 |
# File 'lib/encore/entity/input/exposed_attributes.rb', line 20 def modifiable_attribute?(attribute) modifiable_attributes.include?(attribute) end |
#modifiable_attributes ⇒ Object
Return a list of all attributes that can be modified
30 31 32 |
# File 'lib/encore/entity/input/exposed_attributes.rb', line 30 def modifiable_attributes @exposed_attributes.reject(&:readonly?) end |