Sha256: 7b78d734bc5843c470bca053ff0e8524fced0620e1630ed5bc923632dc0126cd

Contents?: true

Size: 500 Bytes

Versions: 21

Compression:

Stored size: 500 Bytes

Contents

module Flexite
  class BoolEntry < Entry
    def value
      self[:value].to_i == 1 ? true : false
    end

    def form
      Entry::Form.new(attributes.merge(value: self[:value].to_i))
    end

    private

    def check_value
      unless self[:value].respond_to?(:to_i)
        errors.add(:value, 'should respond to #to_i')
        return false
      end

      unless [1, 0].include?(self[:value].to_i)
        errors.add(:value, 'not a valid boolean')
        false
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
flexite-0.0.25 app/models/flexite/bool_entry.rb
flexite-0.0.24 app/models/flexite/bool_entry.rb
flexite-0.0.23 app/models/flexite/bool_entry.rb
flexite-0.0.22 app/models/flexite/bool_entry.rb
flexite-0.0.21 app/models/flexite/bool_entry.rb
flexite-0.0.20 app/models/flexite/bool_entry.rb
flexite-0.0.19 app/models/flexite/bool_entry.rb
flexite-0.0.18 app/models/flexite/bool_entry.rb
flexite-0.0.17 app/models/flexite/bool_entry.rb
flexite-0.0.16 app/models/flexite/bool_entry.rb
flexite-0.0.15 app/models/flexite/bool_entry.rb
flexite-0.0.14 app/models/flexite/bool_entry.rb
flexite-0.0.13 app/models/flexite/bool_entry.rb
flexite-0.0.12 app/models/flexite/bool_entry.rb
flexite-0.0.11 app/models/flexite/bool_entry.rb
flexite-0.0.10 app/models/flexite/bool_entry.rb
flexite-0.0.9 app/models/flexite/bool_entry.rb
flexite-0.0.8 app/models/flexite/bool_entry.rb
flexite-0.0.7 app/models/flexite/bool_entry.rb
flexite-0.0.6 app/models/flexite/bool_entry.rb