Class: EdgycircleToolbox::Sonapi::Blueprint

Inherits:
Object
  • Object
show all
Defined in:
lib/edgycircle_toolbox/sonapi/blueprint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, attribute_names = []) ⇒ Blueprint

Returns a new instance of Blueprint.



6
7
8
9
10
11
12
13
# File 'lib/edgycircle_toolbox/sonapi/blueprint.rb', line 6

def initialize(type, attribute_names = [])
  @type = type
  @attribute_names = attribute_names
  @dynamic_attributes = Proc.new { [] }
  @parameter_filter = Proc.new do |name, value|
    @attribute_names.include?(name.to_s) || name == :id
  end
end

Instance Attribute Details

#attribute_names(object) ⇒ Object

Returns the value of attribute attribute_names.



4
5
6
# File 'lib/edgycircle_toolbox/sonapi/blueprint.rb', line 4

def attribute_names
  @attribute_names
end

#dynamic_attributesObject

Returns the value of attribute dynamic_attributes.



4
5
6
# File 'lib/edgycircle_toolbox/sonapi/blueprint.rb', line 4

def dynamic_attributes
  @dynamic_attributes
end

#parameter_filterObject

Returns the value of attribute parameter_filter.



4
5
6
# File 'lib/edgycircle_toolbox/sonapi/blueprint.rb', line 4

def parameter_filter
  @parameter_filter
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/edgycircle_toolbox/sonapi/blueprint.rb', line 4

def type
  @type
end

Instance Method Details

#add_attribute(attribute_name) ⇒ Object



15
16
17
# File 'lib/edgycircle_toolbox/sonapi/blueprint.rb', line 15

def add_attribute(attribute_name)
  @attribute_names << attribute_name
end

#deserialize_parameter?(name, value) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/edgycircle_toolbox/sonapi/blueprint.rb', line 23

def deserialize_parameter?(name, value)
  parameter_filter.call(name, value)
end