Module: DeadSimpleCMS::Attribute::Type::CollectionSupport
Constant Summary collapse
- VALID_COLLECTION_INPUT_TYPES =
[:select, :radio].freeze
- DEFAULT_COLLECTION_INPUT_TYPE =
:select
Instance Method Summary collapse
-
#collection ⇒ Object
Public: For performance and loading reasons, we allow the ability to pass through a collection as a lambda.
- #initialize(identifier, options = {}) ⇒ Object
Instance Method Details
#collection ⇒ Object
Public: For performance and loading reasons, we allow the ability to pass through a collection as a lambda.
19 20 21 |
# File 'lib/dead_simple_cms/attribute/type/collection_support.rb', line 19 def collection @collection.is_a?(Proc) ? @collection.call : @collection end |
#initialize(identifier, options = {}) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/dead_simple_cms/attribute/type/collection_support.rb', line 10 def initialize(identifier, ={}) if @collection = [:collection] # Pick either the options[:input_type], default_input_type, or the :select. Whichever matches the valid types. [:input_type] = ([[:input_type], default_input_type, DEFAULT_COLLECTION_INPUT_TYPE] & VALID_COLLECTION_INPUT_TYPES).first end super end |