Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ script:
- bundle exec rake
after_success:
# Send coverage report from the job #1 == current MRI release
- '[ "${TRAVIS_JOB_NUMBER#*.}" = "1" ] && [ "$TRAVIS_BRANCH" = "master" ] && bundle exec codeclimate-test-reporter'
- '[ "${TRAVIS_JOB_NUMBER#*.}" = "1" ] && [ "$TRAVIS_BRANCH" = "master" ] && bundle exec codeclimate-test-reporter'
rvm:
- 2.4.0
- 2.3.3
- 2.2.6
- jruby-9.1.6.0
- 2.6.2
- 2.5.5
- 2.4.5
- jruby-9.2.6.0
addons:
code_climate:
repo_token: 2c2c7c253435c02667371778ca886b069d4d24590748fbd7396b9b080016bfa7
Expand Down
2 changes: 1 addition & 1 deletion formalist.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "dry-types", "~> 0.13"
spec.add_runtime_dependency "inflecto"

spec.add_development_dependency "bundler", "~> 1.10"
spec.add_development_dependency "bundler", ">= 1.10", "< 3"
spec.add_development_dependency "rake", "~> 10.4.2"
spec.add_development_dependency "rspec", "~> 3.3.0"
spec.add_development_dependency "simplecov", "~> 0.13.0"
Expand Down
6 changes: 3 additions & 3 deletions lib/formalist/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def initialize(name: nil, attributes: {}, children: [], input: nil, errors: [])
}

# Then run them through the schema
@attributes = Types::Hash.weak(
self.class.attributes_schema.map { |name, defn| [name, defn[:type]] }.to_h
)[all_attributes]
@attributes = Types::Hash.schema(
self.class.attributes_schema.map { |name, defn| [name, defn[:type]] }.to_h,
).safe[all_attributes]

@children = children
@input = input
Expand Down
2 changes: 1 addition & 1 deletion lib/formalist/elements/standard/rich_text_area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RichTextArea < Field
attribute :box_size, Types::String.enum("single", "small", "normal", "large", "xlarge"), default: "normal"
attribute :inline_formatters, Types::Array
attribute :block_formatters, Types::Array
attribute :embeddable_forms, Types::Dependency.constrained(respond_to: :to_h)
attribute :embeddable_forms, Types::Dependency.constrained(case: -> x { x.respond_to?(:call) })

# FIXME: it would be tidier to have a reader method for each attribute
def attributes
Expand Down
10 changes: 3 additions & 7 deletions lib/formalist/types.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# coding: utf-8
require "dry/types"

# TODO: Find a way to avoid registering this globally
Dry::Logic::Predicates.predicate :respond_to? do |method_name, value|
value.respond_to?(method_name)
end

module Formalist
module Types
include Dry::Types.module
Expand All @@ -25,7 +20,8 @@ module Types

Validation = Types::Strict::Hash

Dependency = Types::Object

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function = Dependency.constrained(respond_to: :call)
Dependency = Dry::Types['any']
Function = Dependency.constrained(case: -> x { x.respond_to?(:call) })
end
end