Sha256: 3787793feb212b69b96a9e868b41299c529409fbf134a4ccbb8ac9aaa0fc1bfd

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
encore-0.0.3 lib/encore/entity/input/exposed_attributes.rb