module Encore module Entity module Input module ExposedAttributes extend ActiveSupport::Concern module ClassMethods # Declare a new exposed attribute def expose(column, opts = {}) @exposed_attributes ||= [] @exposed_attributes << Encore::Attribute.new(self, column.to_sym, opts) end # Return whether an attribute is exposed by the entity def exposed_attribute?(attribute) @exposed_attributes.detect { |a| attribute == a } end # Return whether an attribute is exposed by the entity def modifiable_attribute?(attribute) modifiable_attributes.include?(attribute) end # Return a list of all exposed attributes def exposed_attributes @exposed_attributes end # Return a list of all attributes that can be modified def modifiable_attributes @exposed_attributes.reject(&:readonly?) end end end end end end