Sha256: ffe8787ea4b2133484d4891b7f4c457323a0d7baa7f54c2e886907d038eec913

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 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
              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.8.30 lib/ecoportal/api/v2/page/component/selection_option.rb
ecoportal-api-v2-0.8.29 lib/ecoportal/api/v2/page/component/selection_option.rb
ecoportal-api-v2-0.8.28 lib/ecoportal/api/v2/page/component/selection_option.rb
ecoportal-api-v2-0.8.27 lib/ecoportal/api/v2/page/component/selection_option.rb