Class: AssociateJsonb::ArelNodes::Jsonb::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/associate_jsonb/arel_nodes/jsonb/attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relation, name, delegated) ⇒ Attribute

Returns a new instance of Attribute.



10
11
12
13
14
# File 'lib/associate_jsonb/arel_nodes/jsonb/attribute.rb', line 10

def initialize(relation, name, delegated)
  @relation = relation,
  @name = name
  @delegated = delegated
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mthd, *args, **opts, &block) ⇒ Object



32
33
34
# File 'lib/associate_jsonb/arel_nodes/jsonb/attribute.rb', line 32

def method_missing(mthd, *args, **opts, &block)
  delegated.public_send(mthd, *args, **opts, &block)
end

Instance Attribute Details

#delegatedObject (readonly)

Returns the value of attribute delegated.



8
9
10
# File 'lib/associate_jsonb/arel_nodes/jsonb/attribute.rb', line 8

def delegated
  @delegated
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/associate_jsonb/arel_nodes/jsonb/attribute.rb', line 8

def name
  @name
end

#relationObject (readonly)

Returns the value of attribute relation.



8
9
10
# File 'lib/associate_jsonb/arel_nodes/jsonb/attribute.rb', line 8

def relation
  @relation
end

Instance Method Details

#able_to_type_cast?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/associate_jsonb/arel_nodes/jsonb/attribute.rb', line 24

def able_to_type_cast?
  relation.able_to_type_cast?
end

#lowerObject



16
17
18
# File 'lib/associate_jsonb/arel_nodes/jsonb/attribute.rb', line 16

def lower
  relation.lower self
end

#respond_to_missing?(mthd, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/associate_jsonb/arel_nodes/jsonb/attribute.rb', line 28

def respond_to_missing?(mthd, include_private = false)
  delegated.respond_to?(mthd, include_private)
end

#type_cast_for_database(value) ⇒ Object



20
21
22
# File 'lib/associate_jsonb/arel_nodes/jsonb/attribute.rb', line 20

def type_cast_for_database(value)
  relation.type_cast_for_database(name, value)
end