ciesta 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ciesta/field_list.rb +6 -1
- data/lib/ciesta/syncer.rb +1 -1
- data/lib/ciesta/validator.rb +2 -1
- data/lib/ciesta/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 631851224f099bab4b19941f7a13fe52b6e14ed4557941d73e92a6ab2cb64a27
|
4
|
+
data.tar.gz: faa312f16a3ad690460902f3c9a979c99cdc9ae3a01fe04166c157e8975732bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ff82210e4debb0cc8bd1a8dc49a37ec0279c0937c69a7b67a5f6e07364f6ba6e9d36779cd5039b44e0eb55cbe8b498c9251aae5d2a36d5c3682f4a191db3d8e
|
7
|
+
data.tar.gz: a3c9a73fdf55a1ea35833588cc4c67a8eca06e8335224bc30235231d2301922cb6760df8b7e075fdbd951d8abfb5cd14bb7bf4b9508e5fcfccff00e62a82b391
|
data/Gemfile.lock
CHANGED
data/lib/ciesta/field_list.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
# List of object fields
|
4
4
|
#
|
5
|
-
# @api private
|
6
5
|
# @attr_reader [Hash<Symbol, Ciesta::Field>] list Field list
|
7
6
|
class Ciesta::FieldList
|
8
7
|
# Constructor
|
@@ -13,12 +12,14 @@ class Ciesta::FieldList
|
|
13
12
|
# Adds new field to list
|
14
13
|
#
|
15
14
|
# @param [Ciesta::Field] field New field
|
15
|
+
# @api private
|
16
16
|
def <<(field)
|
17
17
|
list[field.name] = field
|
18
18
|
end
|
19
19
|
|
20
20
|
# Getting field by name
|
21
21
|
#
|
22
|
+
# @api private
|
22
23
|
# @param [Symbol] name Field name
|
23
24
|
#
|
24
25
|
# @return [Ciesta::Field]
|
@@ -28,6 +29,7 @@ class Ciesta::FieldList
|
|
28
29
|
|
29
30
|
# Setting field value
|
30
31
|
#
|
32
|
+
# @api private
|
31
33
|
# @param [Symbol] name Field name
|
32
34
|
# @param [any] value Field value
|
33
35
|
def []=(name, value)
|
@@ -59,6 +61,7 @@ class Ciesta::FieldList
|
|
59
61
|
|
60
62
|
# Getting all field names
|
61
63
|
#
|
64
|
+
# @api private
|
62
65
|
# @return [Array<Symbol>]
|
63
66
|
def keys
|
64
67
|
list.keys
|
@@ -66,6 +69,7 @@ class Ciesta::FieldList
|
|
66
69
|
|
67
70
|
# Getting all field values
|
68
71
|
#
|
72
|
+
# @api private
|
69
73
|
# @return [Hash<Symbol, any>]
|
70
74
|
def attributes
|
71
75
|
list.values.each_with_object({}) { |field, mem| mem[field.name] = field.value }
|
@@ -73,6 +77,7 @@ class Ciesta::FieldList
|
|
73
77
|
|
74
78
|
# Iterate over all fields
|
75
79
|
#
|
80
|
+
# @api private
|
76
81
|
# @param [Block] block Block to iterate
|
77
82
|
def each
|
78
83
|
list.each { |name, field| yield(name, field.value) }
|
data/lib/ciesta/syncer.rb
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
# Class for syncing fields and object
|
4
4
|
#
|
5
|
-
# @api private
|
6
5
|
# @attr_reader [Object] object Form objecy
|
7
6
|
# @attr_reader [Ciesta::FieldList] fields Field list
|
8
7
|
class Ciesta::Syncer
|
9
8
|
# Constructor
|
10
9
|
#
|
10
|
+
# @api private
|
11
11
|
# @param [Object] object Form objecr
|
12
12
|
# @param [Ciesta::FieldList] fields Field list
|
13
13
|
def initialize(object, fields)
|
data/lib/ciesta/validator.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
# Validatior class for form
|
4
4
|
#
|
5
|
-
# @api private
|
6
5
|
# @attr_reader [Dry::Validation::Schema] schema Schema for validation
|
7
6
|
# @attr_reader [Hash] errors Array with errors
|
8
7
|
class Ciesta::Validator
|
@@ -15,6 +14,7 @@ class Ciesta::Validator
|
|
15
14
|
|
16
15
|
# Set schema for validation
|
17
16
|
#
|
17
|
+
# @api private
|
18
18
|
# @param [Block] block Block wich returns the schema
|
19
19
|
def use(&block)
|
20
20
|
@schema = Dry::Validation.Form(&block)
|
@@ -24,6 +24,7 @@ class Ciesta::Validator
|
|
24
24
|
#
|
25
25
|
# @param [Hash<Symbol, any>] attributes Attributes to check
|
26
26
|
#
|
27
|
+
# @api private
|
27
28
|
# @return [Boolean]
|
28
29
|
def valid?(attributes)
|
29
30
|
return true if schema.nil?
|
data/lib/ciesta/version.rb
CHANGED