Class: JSI::Schema::Cxt

Inherits:
Object
  • Object
show all
Defined in:
lib/jsi/schema/cxt.rb,
lib/jsi/schema/cxt.rb,
lib/jsi/schema/cxt/child_application.rb,
lib/jsi/schema/cxt/inplace_application.rb

Overview

A Schema::Cxt is the self of a Element action.

Direct Known Subclasses

Block

Defined Under Namespace

Classes: Block, ChildApplication, InplaceApplication

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#schemaJSI::Schema

The schema invoking an action in this context

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/jsi/schema/cxt.rb', line 14

class Cxt
  def subschema(subptr)
    schema.subschema(subptr)
  end

  def schema_content
    schema.jsi_node_content
  end

  def keyword?(keyword)
    schema.keyword?(keyword)
  end

  # @return [Boolean]
  def keyword_value_hash?(keyword)
    keyword?(keyword) && schema_content[keyword].respond_to?(:to_hash)
  end

  # @return [Boolean]
  def keyword_value_ary?(keyword)
    keyword?(keyword) && schema_content[keyword].respond_to?(:to_ary)
  end

  # @return [Boolean]
  def keyword_value_str?(keyword)
    keyword?(keyword) && schema_content[keyword].respond_to?(:to_str)
  end

  # @return [Boolean]
  def keyword_value_bool?(keyword)
    keyword?(keyword) && (schema_content[keyword] == true || schema_content[keyword] == false)
  end

  # @return [Boolean]
  def keyword_value_numeric?(keyword)
    keyword?(keyword) && schema_content[keyword].is_a?(Numeric)
  end

  # is `value` an integer?
  # @return [Boolean]
  def internal_integer?(value)
    value.is_a?(Integer) || (!schema.dialect.conf[:integer_disallows_0_fraction] && value.is_a?(Numeric) && value % 1.0 == 0.0)
  end
end

Instance Method Details

#internal_integer?(value) ⇒ Boolean

is value an integer?

Returns:

  • (Boolean)


54
55
56
# File 'lib/jsi/schema/cxt.rb', line 54

def internal_integer?(value)
  value.is_a?(Integer) || (!schema.dialect.conf[:integer_disallows_0_fraction] && value.is_a?(Numeric) && value % 1.0 == 0.0)
end

#keyword?(keyword) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/jsi/schema/cxt.rb', line 23

def keyword?(keyword)
  schema.keyword?(keyword)
end

#keyword_value_ary?(keyword) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/jsi/schema/cxt.rb', line 33

def keyword_value_ary?(keyword)
  keyword?(keyword) && schema_content[keyword].respond_to?(:to_ary)
end

#keyword_value_bool?(keyword) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/jsi/schema/cxt.rb', line 43

def keyword_value_bool?(keyword)
  keyword?(keyword) && (schema_content[keyword] == true || schema_content[keyword] == false)
end

#keyword_value_hash?(keyword) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/jsi/schema/cxt.rb', line 28

def keyword_value_hash?(keyword)
  keyword?(keyword) && schema_content[keyword].respond_to?(:to_hash)
end

#keyword_value_numeric?(keyword) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/jsi/schema/cxt.rb', line 48

def keyword_value_numeric?(keyword)
  keyword?(keyword) && schema_content[keyword].is_a?(Numeric)
end

#keyword_value_str?(keyword) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/jsi/schema/cxt.rb', line 38

def keyword_value_str?(keyword)
  keyword?(keyword) && schema_content[keyword].respond_to?(:to_str)
end

#schema_contentObject



19
20
21
# File 'lib/jsi/schema/cxt.rb', line 19

def schema_content
  schema.jsi_node_content
end

#subschema(subptr) ⇒ Object



15
16
17
# File 'lib/jsi/schema/cxt.rb', line 15

def subschema(subptr)
  schema.subschema(subptr)
end