Sha256: 94fa9d7c48e54bbf87492d89bec98bb37497a3d41962d79d6dd42bda4c6d1cad

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

module Ecoportal
  module API
    class V2
      class Page
        class Component
          class SelectionOption < Common::Content::DoubleModel

            class << self
              def new_doc
                {
                  "id"         => new_uuid,
                  "weight"     => 9999
                }
              end
            end

            passkey     :id
            passforced  :patch_ver, default: 1
            passthrough :name, :value
            passthrough :weight
            passboolean :selected

            def numeric!
              self.value = block_given?? yield(value) : to_i(value)
            end

            def text!
              self.value = block_given?? yield(value) : value.to_s
            end

            private

            def to_i(value)
              Float(value).to_i
            end

            # https://stackoverflow.com/a/5661695/4352306
            def is_number?(value)
              begin
                true if Float(value)
              rescue ArgumentError => e
                false
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecoportal-api-v2-0.9.1 lib/ecoportal/api/v2/page/component/selection_option.rb
ecoportal-api-v2-0.8.33 lib/ecoportal/api/v2/page/component/selection_option.rb
ecoportal-api-v2-0.8.32 lib/ecoportal/api/v2/page/component/selection_option.rb
ecoportal-api-v2-0.8.31 lib/ecoportal/api/v2/page/component/selection_option.rb