Module: Dbd::Fact::Factory
- Defined in:
- lib/dbd/fact/factory.rb
Class Method Summary collapse
-
.attribute_formats ⇒ Object
Formats for checking CSV fields the predicate, object_type and object are tested in the initializer.
-
.from_string_values(string_values, options = {}) ⇒ Fact, Context
Constructs a Fact or ContextFact from a string values array (e.g. pulled from a CSV row).
-
.new_id ⇒ String
A new id string.
-
.new_subject ⇒ String
A new subject string.
-
.top_class ⇒ Class
The top class for which instances are created here.
Class Method Details
.attribute_formats ⇒ Object
Formats for checking CSV fields the predicate, object_type and object are tested in the initializer
40 41 42 43 44 45 46 47 |
# File 'lib/dbd/fact/factory.rb', line 40 def attribute_formats { id: [true, Fact::ID.valid_regexp], time_stamp: [true, TimeStamp.valid_regexp], context_subject: [false, Fact::Subject.valid_regexp], subject: [true, Fact::Subject.valid_regexp] } end |
.from_string_values(string_values, options = {}) ⇒ Fact, Context
Constructs a Fact or ContextFact from a string values array (e.g. pulled from a CSV row).
31 32 33 34 35 |
# File 'lib/dbd/fact/factory.rb', line 31 def from_string_values(string_values, ={}) string_hash = string_hash_from_values(string_values) validate_string_hash(string_hash) if [:validate] fact_from_values_hash(values_hash(string_hash)) end |
.new_id ⇒ String
Returns A new id string.
21 22 23 |
# File 'lib/dbd/fact/factory.rb', line 21 def new_id top_class::ID.new_id end |
.new_subject ⇒ String
Returns A new subject string.
15 16 17 |
# File 'lib/dbd/fact/factory.rb', line 15 def new_subject top_class::Subject.new_subject end |
.top_class ⇒ Class
Returns the top class for which instances are created here.
9 10 11 |
# File 'lib/dbd/fact/factory.rb', line 9 def top_class Fact end |