Class: Foobara::AttributesTransformers::Only

Inherits:
AttributesTransformers
  • Object
show all
Defined in:
foobara-0.6.1/projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.only_attributesObject

Returns the value of attribute only_attributes.



30
31
32
# File 'projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb', line 30

def only_attributes
  @only_attributes
end

Class Method Details

.symbolObject



32
33
34
35
36
# File 'projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb', line 32

def symbol
  if only_attributes
    symbol_for_attribute_names(only_attributes)
  end
end

.will_set_scoped_path?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb', line 38

def will_set_scoped_path?
  true
end

Instance Method Details

#allowed_keysObject



62
63
64
# File 'projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb', line 62

def allowed_keys
  to_type.element_types.keys
end

#from_type_declarationObject



50
51
52
53
54
55
# File 'projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb', line 50

def from_type_declaration
  if to_type
    to_declaration = to_type.declaration_data
    TypeDeclarations::Attributes.only(to_declaration, *self.class.only_attributes)
  end
end

#to_type_declarationObject



43
44
45
46
47
48
# File 'projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb', line 43

def to_type_declaration
  if from_type
    from_declaration = from_type.declaration_data
    TypeDeclarations::Attributes.only(from_declaration, *self.class.only_attributes)
  end
end

#transform(inputs) ⇒ Object



57
58
59
60
# File 'projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb', line 57

def transform(inputs)
  inputs = Util.symbolize_keys(inputs)
  inputs.slice(*allowed_keys)
end